package com.handinfo.uimenu.window;

import java.io.DataInputStream;
import java.io.IOException;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.StringItem;
import javax.microedition.lcdui.TextField;

import com.handinfo.engine.AbstractGameScene;
import com.handinfo.engine.AbstractGameScreen;
import com.handinfo.engine.GameMIDlet;
import com.handinfo.engine.GameManager;
import com.handinfo.game.AbstractGameActor;
import com.handinfo.game.ActorItem;
import com.handinfo.game.ActorRole;
import com.handinfo.game.Function;
import com.handinfo.uimenu.UIAbstractWindow;
import com.handinfo.uimenu.UIListener;
import com.handinfo.uimenu.UIManager;
import com.handinfo.uimenu.UIMessageBox;
import com.handinfo.uimenu.UIPalette;
import com.handinfo.uimenu.UIPopmenu;
import com.handinfo.uimenu.UITools;
import com.handinfo.uimenu.UIWindowFactory;
import com.handinfo.util.ArrayList;
import com.handinfo.util.Tools;
import com.test.touch.GameTouchManager;

public class UIFamilyWindow extends UIAbstractWindow implements CommandListener
{
	
	protected void actionOnStateChanged()
	{
		System.out.println("m_state="+m_state);
		registerTouch();
	}
	
	private int[][] rect_not_have = new int[][]{
			{190,113,100,24},
			{205,161,71,20},
			{205,183,71,20},
	};
	
	

	protected void registerTouch() {
		super.registerTouch();
		clearAllRects();
		
		switch(m_state) {
		case FAMILY_STATUS_LIST:
			break;
		case FAMILY_STATUS_MESSAGE:
//			drawFamilyOwnMessage(g);
			break;
		case FAMILY_STATUS_MANAGE:
//			drawFamilyManage(g);
			break;
		case FAMILY_STATUS_MEMBER:
//			drawFamilyMember(g);
			break;
		case FAMILY_STATUS_APPLY:
//			drawFamilyApply(g);
			break;
		case FAMILY_STATUS_EVENT:
//			drawFamilyEvent(g);
			break;
		case FAMILY_STATUS_OTHER:
//			drawFamilyOtherMessage(g);
			registerNormalSoft();
			break;
		case FAMILY_STATUS_NOTHAVE:			
//			drawFamilyNoHave(g);
			registerNormalSoft();
			initTouchRect(rect_not_have);
			break;
		case FAMILY_STATUS_LUCKY:
//			drawFamilyLucky(g);
			break;
		}
	}



	protected void onTouchRect(int[][] rect, int touchid) {
		super.onTouchRect(rect, touchid);
		if (rect == rect_not_have) {
			if (m_family_nohave_index == touchid) {
				GameTouchManager.keyPressedFire();
			} else {
				m_family_nohave_index = (short) touchid;
			}
		}
	}



	public UIFamilyWindow(int id)
	{
		super(id);
		initImage();
		initStr();
//		setWindowStatus(FAMILY_STATUS_MESSAGE);
	}
	
	private void initStr(){
		int size = FAMILY_MANAGE_MENU_INFOS[GameManager.getInstance().m_role.m_position].length;
		Tools.debugPrintln("<<<<<<<<<<<<>>>>>>>>>>>>>>>UIFamily size="+size);
		m_family_manage_infos = new String[size][];
		for(int i=0;i<size;i++){
			m_family_manage_infos[i] = Tools.getStrArray(FAMILY_MANAGE_MENU_INFOS[GameManager.getInstance().m_role.m_position][i], UITools.W_RECT-2*AbstractGameScreen.FONT_W);
		}
	}
	private void initImage() {
		m_x = UITools.X_BG;
		m_y = UITools.Y_BG;
		m_w = UITools.W_BG;
		m_h = UITools.H_BG;
//		img_title_small = UIManager.getInstance().createImage(UIManager.RES_TITLE_SMALL);
//		img_title_middle = UIManager.getInstance().createImage(UIManager.RES_TITLE_MIDDLE);
//		img_select_corner = UIManager.getInstance().createImage(UIManager.RES_SELECT_CORNER);
	}

	protected void paintContent(Graphics g)
	{
		switch (m_state) {
			case FAMILY_STATUS_LIST:
//				drawFamilyList(g);
				break;
			case FAMILY_STATUS_MESSAGE:
				drawFamilyOwnMessage(g);
				break;
			case FAMILY_STATUS_MANAGE:
				drawFamilyManage(g);
				break;
			case FAMILY_STATUS_MEMBER:
				drawFamilyMember(g);
				break;
			case FAMILY_STATUS_APPLY:
				drawFamilyApply(g);
				break;
			case FAMILY_STATUS_EVENT:
				drawFamilyEvent(g);
				break;
			case FAMILY_STATUS_OTHER:
				drawFamilyOtherMessage(g);
				break;
			case FAMILY_STATUS_NOTHAVE:
				drawFamilyNoHave(g);
				break;
			case FAMILY_STATUS_LUCKY:
				drawFamilyLucky(g);
				break;
		}
	}
	/**
	 * 家族抽奖界面
	 * @param g
	 */
	private void drawFamilyLucky(Graphics g) {
		UITools.drawWindowBackgroud(g);//绘制背景
		int changerow = 6;
		int row = m_lucky_item_amount / changerow;
		int x = UITools.X_BG + (UITools.W_BG >> 1) - (((row > 0 ? changerow : m_lucky_item_amount) - 1) * (UITools.W_BAG + 10) >> 1);
		int y = UITools.Y_BG + UITools.H_TITLE + 30;
		for (int i = 0; i < m_lucky_item_amount; i++) {
//			x = (AbstractGameScreen.SCREEN_WIDTH >> 1) + (Tools.sin(i * (360 / m_lucky_item_amount)
//					+ m_lucky_angle << Tools.BITS) * (W_LUCKY >> 1) >> Tools.BITS);
//			y = (AbstractGameScreen.SCREEN_HEIGHT >> 1) - (Tools.cos(i * (360 / m_lucky_item_amount)
//					+ m_lucky_angle << Tools.BITS) * (H_LUCKY >> 1) >> Tools.BITS);
			ActorItem.drawIcon(g, x + (i >= changerow ? (i % changerow) : i) * (UITools.W_BAG + 10),
					y + (i >= changerow ? (i / changerow) * (UITools.H_BAG + 10) : 0), Tools.HCENTER_VCENTER, 0,
					m_lucky_item_icon[i], m_lucky_item_cover[i], m_lucky_item_num[i], false);
			if (i == m_lucky_select) {
				UITools.drawImageSelectBox(g, x - (UITools.W_BAG >> 1) - 2 + (i >= changerow ? (i % changerow) : i) * (UITools.W_BAG + 10), 
						y - (UITools.H_BAG >> 1) - 2 + (i >= changerow ? (i / changerow) * (UITools.H_BAG + 10) : 0), UITools.W_BAG + 4, UITools.H_BAG + 4);
			}
		}
		if (m_lucky_message != null) {
			UITools.drawStringList(g, m_lucky_message, UITools.X_BG + 20,
					UITools.Y_BG + (UITools.H_BG >> 1), 0, m_lucky_message.length, Tools.WHITE);
		}
		UITools.drawTitle(g, "家族抽奖");// 绘制标题
		UITools.drawWindowSoftkey(g, m_lucky_start ? 0 : UITools.BUTTON_INDEX_KAISHI, UITools.BUTTON_INDEX_FANHUI);// 绘制左右软键
	}

	/**
	 * 没有家族界面
	 * @param g
	 */
	private void drawFamilyNoHave(Graphics g) {
		UITools.drawWindowBackgroud(g);//绘制背景
		drawFamilyNoHaveMenu(g);//绘制无家族菜单
		UITools.drawTitle(g, "家族");// 绘制标题
		UITools.drawWindowSoftkey(g, UITools.BUTTON_INDEX_QUEDING, UITools.BUTTON_INDEX_FANHUI);// 绘制左右软键
	}
	/**
	 * 没有家族界面菜单
	 * @param g
	 */
	private void drawFamilyNoHaveMenu(Graphics g) {
		int w = AbstractGameScreen.s_font.stringWidth("果果果果果果果果");
		int h = UITools.H_SINGLE_BAR + 2;
		int x = UITools.X_BG + (UITools.W_BG >> 1) - (w >> 1);
		int y = UITools.Y_BG + (UITools.H_BG >> 1) - (h << 1);
		
		if (m_family_nohave_index == FAMILY_NOHAVE_JOIN) {
			g.setColor(0x3A2010);
			g.drawRect(x - 3, y - 3, w + 6, h + 6);
			g.setColor(0xF5FB7C);
			g.fillRect(x - 2, y - 2, w + 5, h + 5);
		}
		g.setColor(0x3A2010);
		g.fillRect(x, y, w, h);
		g.setColor(0xebeb8b);
		g.drawRect(x, y, w, h);
		
		UITools.drawColorString(g, FAMILY_JOIN, AbstractGameScreen.SCREEN_WIDTH >> 1, y - 5, Tools.WHITE, Tools.HCENTER_BOTTOM);
		
		for (int i = 0; i < FAMILY_NO_HAVE.length; i++) {
			UITools.paintLabelStr(g, (AbstractGameScreen.SCREEN_WIDTH >> 1) - (UITools.W_LABEL_HUGE >> 1),
					(AbstractGameScreen.SCREEN_HEIGHT >> 1) + i * UITools.H_BUTTON, UITools.W_LABEL_HUGE, UITools.H_BUTTON, FAMILY_NO_HAVE[i], true);
		}
		if (m_family_nohave_index > FAMILY_NOHAVE_JOIN) {
			UITools.drawImageSelectBox(g, X_FAMILY_MANAGE_MENU - (UITools.W_BUTTON_HUGE >> 1),
					(AbstractGameScreen.SCREEN_HEIGHT >> 1) + (m_family_nohave_index - 1) * UITools.H_BUTTON, UITools.W_BUTTON_HUGE + 1, UITools.H_BUTTON);
		}
	}

	protected void keyLogic()
	{
		switch (m_state) {
			case FAMILY_STATUS_LIST:
				//logicFamilyList();
				break;
			case FAMILY_STATUS_MESSAGE:
				logicFamilyMessage();
				break;
			case FAMILY_STATUS_MANAGE:
				logicFamilyManage();
				break;
			case FAMILY_STATUS_MEMBER:
				logicFamilyMember();
				break;
			case FAMILY_STATUS_APPLY:
				logicFamilyApply();
				break;
			case FAMILY_STATUS_EVENT:
				logicFamilyEvent();
				break;
			case FAMILY_STATUS_OTHER:
				logicFamilyOther();
				break;
			case FAMILY_STATUS_NOTHAVE:
				logicFamilyNoHave();
				break;
			case FAMILY_STATUS_LUCKY:
				logicFamilyLucky();
				break;
		}
		if (++m_timer > 1000000) {
			m_timer = 0;
		}
	}





	private byte m_lucky_select = 0;
	private byte m_lucky_speed = 0;
	private int m_timer = 0;
	private byte m_lucky_result = 0;
	private boolean m_lucky_control = true;//是否接受控制
	private boolean m_lucky_start = false;
	private int m_lucky_wait_time = 0;
	private int LUCKY_WAIT_TIME = 5 * GameManager.FRAME_PER_SECOND;
	private void logicFamilyLucky() {
		if (m_lucky_start) {
			if (m_lucky_control) {
				if (++m_lucky_wait_time > LUCKY_WAIT_TIME) {
					m_lucky_control = false;
				}
			} else {
				if (m_timer % 10 == 0 && m_lucky_speed < 7) {
					m_lucky_speed++;
				}
			}
			if (m_timer % (m_lucky_speed + 1) == 0) {
				if (++m_lucky_select >= m_lucky_item_amount) {
					m_lucky_select = 0;
				}
			}
			if (m_lucky_speed >= 4 && m_lucky_select == m_lucky_result) {
				luckyStop();
				if (m_lucky_item_name != null) {
					GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_B, "恭喜您获得[" + m_lucky_item_name + "]x" + m_lucky_item_len);
				}
			}
		} else {
			if (m_lucky_control) {
				if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
						|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
					GameManager.getInstance().m_game_message.sendFamilyLuckyResult();
				}
				else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
					clearLucky();
					setWindowStatus(FAMILY_STATUS_MANAGE);
				}
			}
		}
	}
	private void clearLucky() {
		m_lucky_select = 0;
		m_lucky_speed = 0;
		m_lucky_result = 0;
		m_lucky_control = true;
		m_lucky_start = false;
		m_lucky_wait_time = 0;
		m_lucky_item_name = null;
		m_lucky_item_len = 0;
		m_lucky_family_lv = 0;
		m_lucky_day_count = 0;
		m_lucky_event_devote = 0;
		m_lucky_surplus_count = 0;
		m_lucky_item_amount = 0;
		m_lucky_item_num = null;
		m_lucky_item_icon = null;
		m_lucky_item_cover = null;
		m_lucky_message = null;
	}
	private void luckyStart() {
		m_lucky_start = true;
		m_lucky_speed = 0;
		m_lucky_wait_time = 0;
	}
	private void luckyStop() {
		m_lucky_start = false;
		m_lucky_control = true;
	}

	private void logicFamilyNoHave() {
		if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)
				|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)) {
			switch (m_family_nohave_index) {
				case FAMILY_NOHAVE_JOIN:
					changeAdvancedScreen("请输入要加入家族的名称", FAMILY_ADVANCED_SHORT);
					break;
				case FAMILY_NOHAVE_LIST:
					GameManager.getInstance().m_game_message.sendRankingList((byte)1,(short) 0, (short)UIRankingLists.LIST_NUMBER);
					break;
				case FAMILY_NOHAVE_CREATE:
					GameManager.getInstance().m_game_message.sendFunction(5501, "");
					break;
			}
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
			setWindowStatus(FAMILY_STATUS_CREATE);
			UIManager.getInstance().removeWindow(this);
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_UP)) {
			m_family_nohave_index = --m_family_nohave_index < 0 ? FAMILY_NOHAVE_CREATE : m_family_nohave_index;
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_DOWN)) {
			m_family_nohave_index = ++m_family_nohave_index > FAMILY_NOHAVE_CREATE ? 0 : m_family_nohave_index;
		}
	}

	/************************逻辑**************************/
	// 家族列表
//	private void logicFamilyList() {
//		if (m_family_list != null && m_family_list.size() > 0) {
//			logicRollTime();
//		}
//		if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
//			setWindowStatus(FAMILY_STATUS_CREATE);
//			UIManager.getInstance().removeWindow(this);
//		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)
//				|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)) {
//			if (m_family_list != null && m_family_list.size() > 0) {
//				m_popmenu = (UIPopmenu)UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_POPMENU);
//				m_popmenu.setPopmenus(new String[]{"申请加入", "查看信息", "返回"});
//				m_popmenu.addListener(new UIListener() {
//					public void actionPerformed() {
//						if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)
//								|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)) {
//							Family family = (Family)m_family_list.elementAt(m_family_list_index);
//							if (m_popmenu.getCurrentIndex() == 0) {
//								GameManager.getInstance().m_game_message.sendFamilyApplyAdd(family.m_id);
//							} else if (m_popmenu.getCurrentIndex() == 1) {
//								GameManager.getInstance().m_game_message.sendFamilyOtherMessage(family.m_id);
//							} else if (m_popmenu.getCurrentIndex() == 2) {
//								UIManager.getInstance().removeWindow(m_popmenu);
//							}
//						} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
//							UIManager.getInstance().removeWindow(m_popmenu);
//						}
//					}
//				});
//			}
//		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_UP)) {
//			if (m_family_list != null && m_family_list.size() > 0) {
//				m_family_list_index = --m_family_list_index < 0 ? m_family_list.size() - 1 : m_family_list_index;
//				Family fam = (Family)m_family_list.elementAt(m_family_list_index);
//				refreshRollTime(AbstractGameScreen.s_font.stringWidth(fam.m_name), W_FAMILY_LIST_NAME);
//			}
//		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_DOWN)) {
//			if (m_family_list != null && m_family_list.size() > 0) {
//				m_family_list_index = ++m_family_list_index >= m_family_list.size() ? 0 : m_family_list_index;
//				Family fam = (Family)m_family_list.elementAt(m_family_list_index);
//				refreshRollTime(AbstractGameScreen.s_font.stringWidth(fam.m_name), W_FAMILY_LIST_NAME);
//			}
//		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT)) {
//			if (m_family_list_amount > 1) {
//				if (m_family_list_page <= 0) {
//					GameManager.getInstance().m_game_message.sendFamilyList((short)(m_family_list_amount - 1), (short)AMOUNT_FAMILY_LIST);
//				} else {
//					GameManager.getInstance().m_game_message.sendFamilyList((short)(m_family_list_page - 1), (short)AMOUNT_FAMILY_LIST);
//				}
//			}
//		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT)) {
//			if (m_family_list_amount > 1) {
//				if (m_family_list_page + 1 >= m_family_list_amount) {
//					GameManager.getInstance().m_game_message.sendFamilyList((short)0, (short)AMOUNT_FAMILY_LIST);
//				} else {
//					GameManager.getInstance().m_game_message.sendFamilyList((short)(m_family_list_page + 1), (short)AMOUNT_FAMILY_LIST);
//				}
//			}
//		}
//	}
	// 家族活动
	private void logicFamilyEvent() {
		if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_B)) {
			if (!GameManager.getInstance().m_game_message.isLockNetwork()) {
				GameManager.getInstance().m_game_message.sendFamilyOwnMessage();
			}
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_D)) {
			if (!GameManager.getInstance().m_game_message.isLockNetwork()) {
				GameManager.getInstance().m_game_message.sendFamilyApplyList((short)m_family_apply_page, (short)AMOUNT_FAMILY_APPLY_LIST);
			}
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
			setWindowStatus(FAMILY_STATUS_CREATE);
			UIManager.getInstance().removeWindow(this);
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
				|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
			if (m_family_event_index == FAMILY_EVENT_LUCKY) {
				GameManager.getInstance().m_game_message.sendFamilyLuckyOpen();
			}
		}
	}
	// 家族申请
	private void logicFamilyApply() {
		if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_B)) {
			m_family_label = FAMILY_STATUS_MESSAGE - 1;
			setWindowStatus(FAMILY_STATUS_MESSAGE);
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_D)) {
			if (!GameManager.getInstance().m_game_message.isLockNetwork()) {
				GameManager.getInstance().m_game_message.sendFamilyMemberList(
						(short)m_family_member_page, (short)AMOUNT_FAMILY_MEMBER_LIST);
			}
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
				|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
			if (m_family_apply_list != null && m_family_apply_list.size() > 0) {
				if (GameManager.getInstance().m_role.m_position > FAMILY_POSITION_MEMBER) {
					m_popmenu = (UIPopmenu)UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_POPMENU);
					m_popmenu.setPopmenus(FAMILY_LIST_MENU);
					m_popmenu.addListener(new UIListener() {
						public void actionPerformed() {
							if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
									|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
								if (m_popmenu.getCurrentIndex() == FAMILY_LIST_AGREE) {
									Function func = (Function)m_family_apply_list.elementAt(m_family_apply_index);
									if (func.m_type == FAMILY_APPLY_TYPE_FAMILY) {
										GameManager.getInstance().m_game_message.sendFamilyRatifyAdd(
												FAMILY_RATIFY_TYPE_FAMILY, func.m_id_long, FAMILY_LIST_AGREE);
									} else if (func.m_type == FAMILY_APPLY_TYPE_ROLE) {
										GameManager.getInstance().m_game_message.sendFamilyRatifyAdd(
												FAMILY_RATIFY_TYPE_ROLE, func.m_id_long, FAMILY_LIST_AGREE);
									}
								} else if (m_popmenu.getCurrentIndex() == FAMILY_LIST_REFUSE) {
									Function func = (Function)m_family_apply_list.elementAt(m_family_apply_index);
									if (func.m_type == FAMILY_APPLY_TYPE_FAMILY) {
										GameManager.getInstance().m_game_message.sendFamilyRatifyAdd(
												FAMILY_RATIFY_TYPE_FAMILY, func.m_id_long, FAMILY_LIST_REFUSE);
									} else if (func.m_type == FAMILY_APPLY_TYPE_ROLE) {
										GameManager.getInstance().m_game_message.sendFamilyRatifyAdd(
												FAMILY_RATIFY_TYPE_ROLE, func.m_id_long, FAMILY_LIST_REFUSE);
									}
								} else if (m_popmenu.getCurrentIndex() == FAMILY_LIST_EXIT) {
									UIManager.getInstance().removeWindow(m_popmenu);
								}
							} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
								UIManager.getInstance().removeWindow(m_popmenu);
							}
						}
					});
				}
			}
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
			setWindowStatus(FAMILY_STATUS_CREATE);
			UIManager.getInstance().removeWindow(this);
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_UP)) {
			if (m_family_apply_list != null && m_family_apply_list.size() > 0) {
				m_family_apply_index = --m_family_apply_index < 0 ? m_family_apply_list.size() - 1 : m_family_apply_index;
			}
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_DOWN)) {
			if (m_family_apply_list != null && m_family_apply_list.size() > 0) {
				m_family_apply_index = ++m_family_apply_index >= m_family_apply_list.size() ? 0 : m_family_apply_index;
			}
		}
	}

	// 家族成员
	private void logicFamilyMember() {
		if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT)) {
			if (!GameManager.getInstance().m_game_message.isLockNetwork() && m_family_member_amount > 1) {
				short page = m_family_member_page;
				page = (short)(++page >= m_family_member_amount ? 0 : page);
				GameManager.getInstance().m_game_message.sendFamilyMemberList(page, (short)AMOUNT_FAMILY_MEMBER_LIST);
			}
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT)) {
			if (!GameManager.getInstance().m_game_message.isLockNetwork() && m_family_member_amount > 1) {
				short page = m_family_member_page;
				page = (short)(--page < 0 ? m_family_member_amount - 1 : page);
				GameManager.getInstance().m_game_message.sendFamilyMemberList(page, (short)AMOUNT_FAMILY_MEMBER_LIST);
			}
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_D)) {//left
			m_family_manage_index = 0;
			m_family_member_page = 0;
			m_family_label = FAMILY_STATUS_MANAGE - 1;
			setWindowStatus(FAMILY_STATUS_MANAGE);
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_B)) {//right
			if (!GameManager.getInstance().m_game_message.isLockNetwork()) {
				GameManager.getInstance().m_game_message.sendFamilyApplyList(
						(short)m_family_apply_page, (short)AMOUNT_FAMILY_APPLY_LIST);
			}
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
			m_family_member_page = 0;
			setWindowStatus(FAMILY_STATUS_CREATE);
			UIManager.getInstance().removeWindow(this);
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_UP)) {
			if (m_family_member_list != null && m_family_member_list.size() > 0) {
				m_family_member_index = --m_family_member_index < 0 ? m_family_member_list.size() - 1 : m_family_member_index;
			}
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_DOWN)) {
			if (m_family_member_list != null && m_family_member_list.size() > 0) {
				m_family_member_index = ++m_family_member_index >= m_family_member_list.size() ? 0 : m_family_member_index;
			}
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)
				|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)) {
			int index = m_family_member_index;
			if (m_family_member_list != null && m_family_member_list.size() > index) {
				final ActorRole role = (ActorRole)m_family_member_list.elementAt(index);
				if (GameManager.getInstance().m_role.m_gameID != role.m_gameID) {
					final byte position = GameManager.getInstance().m_role.m_position;
					switch (position) {
						case FAMILY_POSITION_MEMBER:
							m_popmenu = null;
							m_popmenu = (UIPopmenu)UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_POPMENU);
							m_popmenu.setPopmenus(FAMILY_MEMBER_MENU[position - 1]);
							m_popmenu.addListener(new UIListener() {
								public void actionPerformed() {
									if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)
											|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)) {
										UIManager.getInstance().removeWindow(m_popmenu);
										switch (m_popmenu.getCurrentIndex()) {
											case FAMILY_MEMBER_MENU_MESSAGE://查看信息
												GameManager.getInstance().m_game_message.sendAttInfos(role.m_gameID);
												break;
											case FAMILY_MEMBER_MENU_MAIL://发送信件
												UIMail.sendMailToPlayer(role.m_name);
												break;
										}
									} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
										UIManager.getInstance().removeWindow(m_popmenu);
									} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_KEY1)) {
										GameManager.getInstance().m_game_message.sendAttInfos(role.m_gameID);
									} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_KEY2)) {
										UIMail.sendMailToPlayer(role.m_name);
									}
								}
							});
							break;
						case FAMILY_POSITION_ELDER:
							m_popmenu = null;
							m_popmenu = (UIPopmenu)UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_POPMENU);
							m_popmenu.setPopmenus(FAMILY_MEMBER_MENU[position - 1]);
							m_popmenu.addListener(new UIListener() {
								public void actionPerformed() {
									if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)
											|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)) {
										UIManager.getInstance().removeWindow(m_popmenu);
										switch (m_popmenu.getCurrentIndex()) {
											case FAMILY_MEMBER_MENU_MESSAGE://查看信息
												GameManager.getInstance().m_game_message.sendAttInfos(role.m_gameID);
												break;
											case FAMILY_MEMBER_MENU_MAIL://发送信件
												UIMail.sendMailToPlayer(role.m_name);
												break;
											case FAMILY_MEMBER_MENU_MAILS://发送群信
												UIMail.sendMailToFamily();
												break;
										}
									} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
										UIManager.getInstance().removeWindow(m_popmenu);
									} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_KEY1)) {
										GameManager.getInstance().m_game_message.sendAttInfos(role.m_gameID);
									} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_KEY2)) {
										UIMail.sendMailToPlayer(role.m_name);
									} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_KEY3)) {
										UIMail.sendMailToFamily();
									}
								}
							});
							break;
						case FAMILY_POSITION_SHAIKH:
							m_popmenu = null;
							m_popmenu = (UIPopmenu)UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_POPMENU);
							m_popmenu.setPopmenus(FAMILY_MEMBER_MENU[role.m_position + position - 2]);
							m_popmenu.addListener(new UIListener() {
								public void actionPerformed() {
									if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)
											|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)) {
										UIManager.getInstance().removeWindow(m_popmenu);
										switch (m_popmenu.getCurrentIndex()) {
											case FAMILY_MEMBER_MENU_MESSAGE://查看信息
												GameManager.getInstance().m_game_message.sendAttInfos(role.m_gameID);
												break;
											case FAMILY_MEMBER_MENU_MAIL://发送信件
												UIMail.sendMailToPlayer(role.m_name);
												break;
											case FAMILY_MEMBER_MENU_MAILS://发送群信
												UIMail.sendMailToFamily();
												break;
											case FAMILY_MEMBER_MENU_EXPEL://开除成员
												logicAskedDismiss();
												break;
											case FAMILY_MEMBER_MENU_ABDICATE://禅让族长
												final UIMessageBox uimb = (UIMessageBox)UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_MESSAGEBOX);
												uimb.setMessage("是否将族长职位让与" + role.m_name + "?");
												uimb.addListener(new UIListener() {
													public void actionPerformed() {
														if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)) {
															GameManager.getInstance().m_game_message.sendFamilyDemiseSheikh(role.m_gameID);
															UIManager.getInstance().removeWindow(uimb);
														} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
															UIManager.getInstance().removeWindow(uimb);
														}
													}
												});
												break;
											case FAMILY_MEMBER_MENU_ELDER://提拔/免职长老
												if (role.m_position == FAMILY_POSITION_MEMBER) {
													final UIMessageBox mbox = (UIMessageBox)UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_MESSAGEBOX);
													mbox.setMessage("是否将" + role.m_name + "提拔为长老?");
													mbox.addListener(new UIListener() {
														public void actionPerformed() {
															if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)) {
																GameManager.getInstance().m_game_message.sendFamilySetElder(FAMILY_SETELDER_PROMOTION, role.m_gameID);
																UIManager.getInstance().removeWindow(mbox);
															} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
																UIManager.getInstance().removeWindow(mbox);
															}
														}
													});
												} else if (role.m_position == FAMILY_POSITION_ELDER) {
													final UIMessageBox mbox = (UIMessageBox)UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_MESSAGEBOX);
													mbox.setMessage("是否将长老" + role.m_name + "免职?");
													mbox.addListener(new UIListener() {
														public void actionPerformed() {
															if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)) {
																GameManager.getInstance().m_game_message.sendFamilySetElder(FAMILY_SETELDER_DEPOSE, role.m_gameID);
																UIManager.getInstance().removeWindow(mbox);
															} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
																UIManager.getInstance().removeWindow(mbox);
															}
														}
													});
												}
												break;
										}
									} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
										UIManager.getInstance().removeWindow(m_popmenu);
									} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_KEY1)) {
										GameManager.getInstance().m_game_message.sendAttInfos(role.m_gameID);
									} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_KEY2)) {
										UIMail.sendMailToPlayer(role.m_name);
									} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_KEY3)) {
										UIMail.sendMailToFamily();
									} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_KEY4)) {
										logicAskedDismiss();
									} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_KEY5)) {
										final UIMessageBox uimb = (UIMessageBox)UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_MESSAGEBOX);
										uimb.setMessage("是否将族长职位让与" + role.m_name + "?");
										uimb.addListener(new UIListener() {
											public void actionPerformed() {
												if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)) {
													GameManager.getInstance().m_game_message.sendFamilyDemiseSheikh(role.m_gameID);
													UIManager.getInstance().removeWindow(uimb);
												} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
													UIManager.getInstance().removeWindow(uimb);
												}
											}
										});
									} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_KEY6)) {
										if (role.m_position == FAMILY_POSITION_MEMBER) {
											final UIMessageBox mbox = (UIMessageBox)UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_MESSAGEBOX);
											mbox.setMessage("是否将" + role.m_name + "提拔为长老?");
											mbox.addListener(new UIListener() {
												public void actionPerformed() {
													if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)) {
														GameManager.getInstance().m_game_message.sendFamilySetElder(FAMILY_SETELDER_PROMOTION, role.m_gameID);
														UIManager.getInstance().removeWindow(mbox);
													} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
														UIManager.getInstance().removeWindow(mbox);
													}
												}
											});
										} else if (role.m_position == FAMILY_POSITION_ELDER) {
											final UIMessageBox mbox = (UIMessageBox)UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_MESSAGEBOX);
											mbox.setMessage("是否将长老" + role.m_name + "免职?");
											mbox.addListener(new UIListener() {
												public void actionPerformed() {
													if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)) {
														GameManager.getInstance().m_game_message.sendFamilySetElder(FAMILY_SETELDER_DEPOSE, role.m_gameID);
														UIManager.getInstance().removeWindow(mbox);
													} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
														UIManager.getInstance().removeWindow(mbox);
													}
												}
											});
										}
									}
								}
							});
							break;
					}
				} else {
					GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "这是您自己!");
				}
			}
		}
	}
	// 家族管理
	private void logicFamilyManage() {
		if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_UP)) {
			if (m_open_donate_list) {
				if (m_donate_list_name != null) {
					byte[] result = UITools.keyPressedIndexPage(m_donate_index, m_donate_page, m_donate_list_name.length,
							UITools.AMOUNT_SMALL_CONTENT, UITools.OPERATION_MINUS);
					m_donate_index = result[UITools.KPIP_INDEX];
					m_donate_page = result[UITools.KPIP_PAGE];
				}
			} else {
				if (m_family != null) {
					if (GameManager.getInstance().m_role.m_position == FAMILY_POSITION_SHAIKH && m_family.m_dismiss_time > 0) {
					} else {
						int size = FAMILY_MANAGE_MENU[GameManager.getInstance().m_role.m_position - 1].length - 1;
						if( GameManager.getInstance().m_role.m_position == FAMILY_POSITION_SHAIKH ){
							if( m_family_manage_index == 0 || m_family_manage_index == 3){
								m_family_manage_index = 6;
							}else{
								m_family_manage_index = --m_family_manage_index < 0 ? size : m_family_manage_index;
							}
						}else{
							m_family_manage_index = --m_family_manage_index < 0 ? size : m_family_manage_index;
						}
						
					}
				}
			}
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_DOWN)) {
			if (m_open_donate_list) {
				byte[] result = UITools.keyPressedIndexPage(m_donate_index, m_donate_page, m_donate_list_name.length,
						UITools.AMOUNT_SMALL_CONTENT, UITools.OPERATION_ADD);
				m_donate_index = result[UITools.KPIP_INDEX];
				m_donate_page = result[UITools.KPIP_PAGE];
			} else {
				if (m_family != null) {
					if (GameManager.getInstance().m_role.m_position == FAMILY_POSITION_SHAIKH && m_family.m_dismiss_time > 0) {
					} else {
						if (GameManager.getInstance().m_role.m_position == 0) {
							return;
						}
						int size = FAMILY_MANAGE_MENU[GameManager.getInstance().m_role.m_position - 1].length - 1;
						if( GameManager.getInstance().m_role.m_position == FAMILY_POSITION_SHAIKH ){
							if( m_family_manage_index == 2 || m_family_manage_index == 5){
								m_family_manage_index = 6;
							}else{
								m_family_manage_index = ++m_family_manage_index > size ? 0 : m_family_manage_index;
							}
						}else{
							m_family_manage_index = ++m_family_manage_index > size ? 0 : m_family_manage_index;
						}
						
					}
				}
			}
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT)) {
			if (m_open_donate_list) {
				if (m_donate_list_num != null && m_donate_list_amount != null) {
					int num = m_donate_list_num[m_donate_page + m_donate_index];
					m_donate_list_num[m_donate_page + m_donate_index] = --num < 0 ? m_donate_list_amount[m_donate_page + m_donate_index] : num;
				}
			}else{
				if( GameManager.getInstance().m_role.m_position == FAMILY_POSITION_SHAIKH ){
					if( m_family_manage_index > 2 && m_family_manage_index != (FAMILY_MANAGE_MENU[GameManager.getInstance().m_role.m_position - 1].length-1)){
						m_family_manage_index -= 3;
					}
				}
			}
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT)) {
			if (m_open_donate_list) {
				if (m_donate_list_num != null && m_donate_list_amount != null) {
					int num = m_donate_list_num[m_donate_page + m_donate_index];
					m_donate_list_num[m_donate_page + m_donate_index] = ++num > m_donate_list_amount[m_donate_page + m_donate_index] ? 0 : num;
				}
			}else {
				if( GameManager.getInstance().m_role.m_position == FAMILY_POSITION_SHAIKH ){
					if( m_family_manage_index < 3 ){
						m_family_manage_index += 3;
					}
				}
			}
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_D)) {//left
			if (!GameManager.getInstance().m_game_message.isLockNetwork()) {
				GameManager.getInstance().m_game_message.sendFamilyOwnMessage();
			}
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_B)) {//right
			if (!GameManager.getInstance().m_game_message.isLockNetwork()) {
				GameManager.getInstance().m_game_message.sendFamilyMemberList(
						(short)m_family_member_page, (short)AMOUNT_FAMILY_MEMBER_LIST);
			}
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
				|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
			if (m_open_donate_list) {
				getDonateAmount();
			} else {
				manageKeyLogic();
			}
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
			if (m_open_donate_list) {
				m_open_donate_list = false;
			} else {
				setWindowStatus(FAMILY_STATUS_CREATE);
				UIManager.getInstance().removeWindow(this);
			}
		}
		if (GameManager.getInstance().m_role.m_position == FAMILY_POSITION_SHAIKH && m_family != null && m_family.m_dismiss_time > 0) {
			if (GameManager.getInstance().m_scene.m_frameCount % GameManager.FRAME_PER_SECOND == 0) {
				if (m_family.m_dismiss_time > 2) {
					m_family.m_dismiss_time--;
					String temp = FAMILY_DISMISS_HINT1 + UITools.getTimeBySecond(m_family.m_dismiss_time) + FAMILY_DISMISS_HINT2;
					m_family_dismiss_hint = UITools.splitString(temp, UITools.W_BG - UITools.H_WIN_SIDE);
				}
			}
		}
	}
	private String[] m_donate_list_name = null;//可捐献的物品列表 名字
	private String[] m_donate_list_key = null;//可捐献的物品列表 key
	private int[] m_donate_list_num = null;//可捐献的物品列表 当前选择数量
	private int[] m_donate_list_amount = null;//可捐献的物品列表 总数
	private boolean m_open_donate_list = false;//是否开启捐献列表
	private byte m_donate_index = 0;//当前选择索引
	private byte m_donate_page = 0;//当前翻页页数
	/**
	 * 遍历已经选择的捐献物资
	 */
	public void getDonateAmount() {
		int amount = 0;
		String[] keys = new String[m_donate_list_num.length];
		int[] num = new int[m_donate_list_num.length];
		if (m_donate_list_num != null) {
			for (int i = 0, k = 0; i < m_donate_list_num.length; i++) {
				if (m_donate_list_num[i] > 0) {
					keys[k] = m_donate_list_key[i];
					num[k] = m_donate_list_num[i];
					k++;
					amount++;
				}
			}
			if (amount > 0) {
				GameManager.getInstance().m_game_message.sendFamilyDonate((short)amount, keys, num);
			}
		}
	}
	/**
	 * 遍历背包得到所有能捐献的物资
	 */
	public void getDonateByBag() {
		m_open_donate_list = false;
		m_donate_index = 0;
		m_donate_page = 0;
		
		m_donate_list_name = null;
		m_donate_list_num = null;
		m_donate_list_amount = null;
		ArrayList donate_list = null;
		
		ActorItem[] bags = GameManager.getInstance().m_role.m_bag_goods;
		for (int i = 0; i < bags.length; i++) {
			if (bags[i] != null && bags[i].m_type == ActorItem.TYPE_GOODS_MATERIAL
					&& (bags[i].m_type_detail == ActorItem.TYPE_MATERIAL_NORMAL)){
//					|| bags[i].m_type_detail == ActorItem.TYPE_MATERIAL_FUNCTION)) {
				if (donate_list == null) {
					donate_list = new ArrayList();
				}
				donate_list.addElement(bags[i]);
			}
//			if (bags[i] != null && bags[i].m_type > ActorItem.TYPE_GOODS_ALL) {
//				if (donate_list == null) {
//					donate_list = new ArrayList();
//				}
//				donate_list.addElement(bags[i]);
//			}
		}
		if (donate_list != null) {
			ActorItem item = null;
			m_donate_list_name = new String[donate_list.size()];
			m_donate_list_key = new String[donate_list.size()];
			m_donate_list_num = new int[donate_list.size()];
			m_donate_list_amount = new int[donate_list.size()];
			for (int i = 0; i < donate_list.size(); i++) {
				item = (ActorItem)donate_list.elementAt(i);
				m_donate_list_name[i] = item.m_name;
				m_donate_list_amount[i] = item.m_num;
				m_donate_list_key[i] = item.m_key;
			}
			m_open_donate_list = true;
		} else {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "没有可捐献的物资");
		}
		Tools.debugPrintln("m_open_donate_list : " + m_open_donate_list);
	}
	
	
	private void manageKeyLogic() {
		if (m_family != null) {
			if (GameManager.getInstance().m_role.m_position == FAMILY_POSITION_SHAIKH && m_family.m_dismiss_time > 0) {
				final UIMessageBox mb = (UIMessageBox)UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_MESSAGEBOX);
				mb.setMessage("确认要取消家族解散?");
				mb.addListener(new UIListener() {
					public void actionPerformed() {
						if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
								|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
							GameManager.getInstance().m_game_message.sendFamilyCancelDismiss();
							UIManager.getInstance().removeWindow(mb);
						} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
							UIManager.getInstance().removeWindow(mb);
						}
					}
				});
			} else {
				byte position = GameManager.getInstance().m_role.m_position;
				switch (position) {
					case FAMILY_POSITION_MEMBER:
						switch (m_family_manage_index) {
							case FAMILY_MANAGE_MEMBER_DONATE://成员 - 捐献物资
								getDonateByBag();
								break;
							case FAMILY_MANAGE_MEMBER_LUCKY://
								GameManager.getInstance().m_game_message.sendFamilyLuckyOpen();
								break;
							case FAMILY_MANAGE_MEMBER_EXIT://成员 - 退出家族
								logicAskedLeave();
								break;
							case FAMILY_MANAGE_MEMBER_SHOP://成员 - 家族商店
								logicOpenListFamilyShop();
								break;
						}
						break;
					case FAMILY_POSITION_ELDER:
						switch (m_family_manage_index) {
							case FAMILY_MANAGE_ELDER_DONATE://长老 - 捐献物资
								getDonateByBag();
								break;
							case  FAMILY_MANAGE_ELDER_LUCKY:
							    GameManager.getInstance().m_game_message.sendFamilyLuckyOpen();
							    break;
							case FAMILY_MANAGE_ELDER_INVITE://长老 - 邀请入族
								changeAdvancedScreen("请输入邀请的玩家名称", FAMILY_ADVANCED_SHORT);
								break;
							case FAMILY_MANAGE_ELDER_EXIT://长老  - 退出家族
								logicAskedLeave();
								break;
							case FAMILY_MANAGE_ELDER_SHOP://成员 - 家族商店
								logicOpenListFamilyShop();
								break;
						}
						break;
					case FAMILY_POSITION_SHAIKH:
						switch (m_family_manage_index) {
							case FAMILY_MANAGE_SHAIKH_DONATE://族长 - 捐献物资
								getDonateByBag();
								break;
							case  FAMILY_MANAGE_SHAIKH_LUCKY:
							    GameManager.getInstance().m_game_message.sendFamilyLuckyOpen();
							    break;
							case FAMILY_MANAGE_SHAIKH_INVITE://族长 - 邀请入族
								changeAdvancedScreen("请输入邀请的玩家名称", FAMILY_ADVANCED_SHORT);
								break;
							case FAMILY_MANAGE_SHAIKH_MERGE://族长 - 家族合并
								changeAdvancedScreen("请输入要合并的家族名称", FAMILY_ADVANCED_SHORT);
								break;
							case FAMILY_MANAGE_SHAIKH_DISMISS://族长 - 家族解散
								final UIMessageBox mb = (UIMessageBox)UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_MESSAGEBOX);
								mb.setMessage("确定要解散家族?");
								mb.addListener(new UIListener() {
									public void actionPerformed() {
										if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
												|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
											GameManager.getInstance().m_game_message.sendFamilyDismiss();
											UIManager.getInstance().removeWindow(mb);
										} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
											UIManager.getInstance().removeWindow(mb);
										}
									}
								});
								break;
							case FAMILY_MANAGE_SHAIKH_EXIT://族长  - 退出家族
								logicAskedLeave();
								break;
							case FAMILY_MANAGE_SHAIKH_SHOP://成员 - 家族商店
								logicOpenListFamilyShop();
								break;
						}
						break;
				}
			}
		}
	}
	//请求家族商店列表
	private void logicOpenListFamilyShop()
	{
		GameManager.getInstance().m_game_message.sendOpenFamilyShopList();
	}

	// 家族信息
	private void logicFamilyMessage() {
		if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
			setWindowStatus(FAMILY_STATUS_CREATE);
			UIManager.getInstance().removeWindow(this);
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)
				|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)) {
			if (GameManager.getInstance().m_role.m_position == FAMILY_POSITION_SHAIKH) {
				final UIPopmenu menu = (UIPopmenu)UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_POPMENU);
				menu.setPopmenus(FAMILY_MESSAGE_MENU);
				menu.addListener(new UIListener() {
					public void actionPerformed() {
						if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)
								|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)) {
							if (menu.getCurrentIndex() == FAMILY_MESSAGE_MENU_MANIFESTO) {
								m_message_menu_status = FAMILY_MESSAGE_MENU_MANIFESTO;
								UIManager.getInstance().removeWindow(menu);
								changeAdvancedScreen("请输入新的家族宣言", FAMILY_ADVANCED_LONG);
							} else if (menu.getCurrentIndex() == FAMILY_MESSAGE_MENU_NOTICE) {
								m_message_menu_status = FAMILY_MESSAGE_MENU_NOTICE;
								UIManager.getInstance().removeWindow(menu);
								changeAdvancedScreen("请输入新的家族公告", FAMILY_ADVANCED_LONG);
							}
						} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
							UIManager.getInstance().removeWindow(menu);
						}
					}
				});
			}
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_UP)) {
			m_family_message_page = --m_family_message_page < 0 ? 0 : m_family_message_page;
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_DOWN)) {
			m_family_message_page = ++m_family_message_page >
				(m_family_message.length - UITools.AMOUNT_SUBCOAT_HT_CONTENT) ? (--m_family_message_page) : m_family_message_page;
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_D)) {
			m_family_message_page = 0;
			m_family_label = FAMILY_STATUS_APPLY - 1;
//			setWindowStatus(FAMILY_STATUS_EVENT);
			setWindowStatus(FAMILY_STATUS_APPLY);
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_B)) {
			m_family_message_page = 0;
			m_family_manage_index = 0;
			m_family_label = FAMILY_STATUS_MANAGE - 1;
			setWindowStatus(FAMILY_STATUS_MANAGE);
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
			setWindowStatus(FAMILY_STATUS_CREATE);
			UIManager.getInstance().removeWindow(this);
		}
	}
	/**
	 * 其他家族信息
	 */
	private void logicFamilyOther() {
		if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
			setWindowStatus(FAMILY_STATUS_CREATE);
			UIManager.getInstance().removeWindow(this);
		}
	}
	/**
	 * 询问是否要离开家族
	 */
	private void logicAskedLeave() {
		m_messagebox = null;
		m_messagebox = (UIMessageBox)UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_MESSAGEBOX);
		m_messagebox.setMessage("您确认要离开家族?");
		m_messagebox.addListener(new UIListener() {
			public void actionPerformed() {
				if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
						|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
					GameManager.getInstance().m_game_message.sendFamilyConfirmLeave();
				} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
					UIManager.getInstance().removeWindow(m_messagebox);
				}
			}
		});
	}
	/**
	 * 询问是否要开除成员
	 */
	private void logicAskedDismiss() {
		m_messagebox = null;
		m_messagebox = (UIMessageBox)UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_MESSAGEBOX);
		m_messagebox.setMessage("您确认要开除此成员?");
		m_messagebox.addListener(new UIListener() {
			public void actionPerformed() {
				if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
						|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
					ActorRole role = (ActorRole)m_family_member_list.elementAt(m_family_member_index);
					GameManager.getInstance().m_game_message.sendFamilyExpel(role.m_gameID);
				} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
					UIManager.getInstance().removeWindow(m_messagebox);
				}
			}
		});
	}
	/************************绘制**************************/
	// 绘制家族标签
	private void drawFamilyLabel(Graphics g) {
		for (int i = 0, x = 0; i < AMOUNT_FAMILY_LABEL_PAGE; i++) {
			x = UITools.X_BUTTON_3BIG + UITools.W_BUTTON_BIG * i;
			g.setClip(x, UITools.Y_BUTTON, UITools.W_BUTTON_BIG, UITools.H_BUTTON);
			switch (i) {
				case FAMILY_LABEL_PRIOR:
//					g.drawImage(img_label_big[LABEL_BIG_NO], x, UITools.Y_BUTTON, Tools.LEFT_TOP);
					UITools.paintLabel(g, x, UITools.Y_BUTTON, UITools.W_LABEL_BIG, UITools.H_LABEL, false);
					UITools.drawColorString(g, FAMILY_LABEL[m_family_label - 1 < 0 ? FAMILY_LABEL.length - 1 : m_family_label - 1],
							x + (UITools.W_BUTTON_BIG >> 1),
							UITools.Y_BUTTON + (UITools.H_BUTTON >> 1) - (AbstractGameScreen.FONT_H >> 1),
							UIManager.getPaletteColor(UIPalette.COLOR_WORD_NOS), Tools.HCENTER_TOP);
					break;
				case FAMILY_LABEL_CURRENT:
//					g.drawImage(img_label_big[LABEL_BIG_YES], x, UITools.Y_BUTTON, Tools.LEFT_TOP);
					UITools.paintLabel(g, x, UITools.Y_BUTTON, UITools.W_LABEL_BIG, UITools.H_LABEL, true);
					UITools.drawColorString(g, FAMILY_LABEL[m_family_label],
							x + (UITools.W_BUTTON_BIG >> 1),
							UITools.Y_BUTTON + (UITools.H_BUTTON >> 1) - (AbstractGameScreen.FONT_H >> 1),
							UIManager.getPaletteColor(UIPalette.COLOR_WORD_NOS), Tools.HCENTER_TOP);
//					if (!m_list_or_label) {
						UITools.drawImageSelectBox(g, x, UITools.Y_BUTTON, UITools.W_BUTTON_BIG, UITools.H_BUTTON);
//					}
					break;
				case FAMILY_LABEL_NEXT:
//					g.drawImage(img_label_big[LABEL_BIG_NO], x, UITools.Y_BUTTON, Tools.LEFT_TOP);
					UITools.paintLabel(g, x, UITools.Y_BUTTON, UITools.W_LABEL_BIG, UITools.H_LABEL, false);
					UITools.drawColorString(g, FAMILY_LABEL[m_family_label + 1 >= FAMILY_LABEL.length ? 0 : m_family_label + 1],
							x + (UITools.W_BUTTON_BIG >> 1),
							UITools.Y_BUTTON + (UITools.H_BUTTON >> 1) - (AbstractGameScreen.FONT_H >> 1),
							UIManager.getPaletteColor(UIPalette.COLOR_WORD_NOS), Tools.HCENTER_TOP);
					break;
			}
		}
		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
		UITools.drawLabelArrows(g, UITools.X_BUTTON_3BIG, UITools.Y_BUTTON, UITools.W_BUTTON_BIG * AMOUNT_FAMILY_LABEL_PAGE, true, true);
	}
	/**
	 * 绘制管理界面菜单
	 * @param g
	 */
	private void drawFaimlyManageMenu(Graphics g) {
		if (GameManager.getInstance().m_role.m_position > FAMILY_MANAGE_MENU.length) {
			Tools.debugPrintln("玩家职位大于正常长度 : " + GameManager.getInstance().m_role.m_position);
			return;
		}
		if (GameManager.getInstance().m_role.m_position == 0) {
			return;
		}
		String[] temp = FAMILY_MANAGE_MENU[GameManager.getInstance().m_role.m_position - 1];
		//int sy = Y_FAMILY_MANAGE_MENU - (temp.length * UITools.H_BUTTON >> 1);
		int sy = Y_FAMILY_MANAGE_MENU;
		int sx = UITools.X_BG + ((UITools.W_BG-2*(UITools.W_BUTTON_HUGE+UITools.GAP_WINDOW_SUBCOAT_UP))>> 1);
		int sm = FAMILY_MANAGE_MENU_LIST_NUM - temp.length;
		if( sm  > 0 ){
			sy += ((sm*UITools.H_BUTTON) >> 1);
		}
		switch(GameManager.getInstance().m_role.m_position){
			case FAMILY_POSITION_MEMBER:
			case FAMILY_POSITION_ELDER:
				for (int i = 0, y = 0; i < temp.length; i++) {
					y = sy + i * UITools.H_BUTTON;
					g.setClip(X_FAMILY_MANAGE_MENU - (UITools.W_BUTTON_HUGE >> 1), y, UITools.W_BUTTON_HUGE, UITools.H_BUTTON);
					if (i == m_family_manage_index) {
						UITools.paintLabelStr(g, X_FAMILY_MANAGE_MENU - (UITools.W_LABEL_HUGE >> 1), y, UITools.W_LABEL_HUGE, UITools.H_LABEL, temp[i], true);
						UITools.drawImageSelectBox(g, X_FAMILY_MANAGE_MENU - (UITools.W_BUTTON_HUGE >> 1),
								y, UITools.W_BUTTON_HUGE, UITools.H_BUTTON);
					} else {
						UITools.paintLabelStr(g, X_FAMILY_MANAGE_MENU - (UITools.W_LABEL_HUGE >> 1), y, UITools.W_LABEL_HUGE, UITools.H_LABEL, temp[i], false);
					}
				}
				break;
			case FAMILY_POSITION_SHAIKH:
				sy += (UITools.H_BUTTON >> 1);
				for (int i = 0, y = 0; i < 3; i++) {
					y = sy + i * (UITools.H_BUTTON+2*UITools.GAP_WINDOW_SUBCOAT_UP);
					g.setClip( sx, y, UITools.W_BUTTON_HUGE, UITools.H_BUTTON);
					if (i == m_family_manage_index) {
						UITools.paintLabelStr(g, sx, y, UITools.W_LABEL_HUGE, UITools.H_LABEL, temp[i], true);
						UITools.drawImageSelectBox(g, sx,y, UITools.W_BUTTON_HUGE, UITools.H_BUTTON);
					} else {
						UITools.paintLabelStr(g, sx, y, UITools.W_LABEL_HUGE, UITools.H_LABEL, temp[i], false);
					}
				}
				sx += 2*UITools.GAP_WINDOW_SUBCOAT_UP+UITools.W_BUTTON_HUGE;
				for (int i = 3, y = 0; i < 6; i++) {
					y = sy + (i-3) * (UITools.H_BUTTON+2*UITools.GAP_WINDOW_SUBCOAT_UP);
					g.setClip(sx, y, UITools.W_BUTTON_HUGE, UITools.H_BUTTON);
					if (i == m_family_manage_index) {
						UITools.paintLabelStr(g, sx, y, UITools.W_LABEL_HUGE, UITools.H_LABEL, temp[i], true);
						UITools.drawImageSelectBox(g, sx,y, UITools.W_BUTTON_HUGE, UITools.H_BUTTON);
					} else {
						UITools.paintLabelStr(g, sx, y, UITools.W_LABEL_HUGE, UITools.H_LABEL, temp[i], false);
					}
				}
				sx = X_FAMILY_MANAGE_MENU - (UITools.W_LABEL_HUGE >> 1);
				int y = sy + 3 * (UITools.H_BUTTON+2*UITools.GAP_WINDOW_SUBCOAT_UP);
				g.setClip(sx, y, UITools.W_BUTTON_HUGE, UITools.H_BUTTON);
				int index = temp.length -1;
				if ( index == m_family_manage_index ) {
					UITools.paintLabelStr(g, sx, y, UITools.W_LABEL_HUGE, UITools.H_LABEL, temp[index], true);
					UITools.drawImageSelectBox(g, sx,y, UITools.W_BUTTON_HUGE, UITools.H_BUTTON);
				} else {
					UITools.paintLabelStr(g, sx, y, UITools.W_LABEL_HUGE, UITools.H_LABEL, temp[index], false);
				}
				break;
		}
		
		//绘制框
		int tempX = UITools.X_BG + UITools.INITX_CONTENT;
		int tempY = Y_FAMILY_MANAGE_MENU_INFOS;
		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
		UITools.paintContentRect(g, tempX, tempY, UITools.W_RECT, H_FAMILY_MANAGE_MENU_INFOS);
		//绘制信息介绍
		tempX = UITools.X_BG + UITools.INITX_CONTENT + AbstractGameScreen.FONT_W;
		tempY = Y_FAMILY_MANAGE_MENU_INFOS + 4;
//		Tools.debugPrintln("m_family_manage_index="+m_family_manage_index);
		if(m_family_manage_infos != null){
			if( m_family_manage_index > m_family_manage_infos.length - 1){
				return;
			}
			if( m_family_manage_infos[m_family_manage_index] != null){
				int num =  m_family_manage_infos[m_family_manage_index].length;
				g.setColor(0xFFFFFF);
				for( int i= 0;i<num;i++ ){
					g.drawString( m_family_manage_infos[m_family_manage_index][i], tempX, tempY + i*(AbstractGameScreen.FONT_H), 0);
				}
			}
		}
	}
	//家族自己家族信息
	private void drawFamilyOwnMessage(Graphics g) {
		UITools.drawWindowBackgroud(g);//绘制背景
		drawFamilyLabel(g);//绘制标签
		UITools.drawWindowSubcoat(g,//内层背景
				UITools.X_SUBCOAT_HT, UITools.Y_SUBCOAT_HT,
				UITools.W_SUBCOAT_HT, UITools.H_SUBCOAT_HT, UIManager.getPaletteColor(UIPalette.COLOR_CBD_DEEP));
//		if (m_list_or_label == FAMILY_FOCUS_LIST) {
			UITools.drawImageSelectBox(g, UITools.X_SUBCOAT_HT - 5,
					UITools.Y_SUBCOAT_HT - 5, UITools.W_SUBCOAT_HT + 10, UITools.H_SUBCOAT_HT + 10);
//		}
		UITools.drawStringList(g,
				m_family_message,
				UITools.X_SUBCOAT_HT + UITools.GAP_LEFT,
				UITools.Y_SUBCOAT_HT + UITools.GAP_UP,
				m_family_message_page, UITools.AMOUNT_SUBCOAT_HT_CONTENT, UIManager.getPaletteColor(UIPalette.COLOR_WORD_NOS));
		if (m_family_message != null && m_family_message.length > UITools.AMOUNT_SUBCOAT_HT_CONTENT) {
			UITools.paintScrollBar(g, UITools.X_SUBCOAT_HT + UITools.W_SUBCOAT_HT,
					UITools.Y_SUBCOAT_HT, UITools.H_SUBCOAT_HT,
					m_family_message_page * 100 / (m_family_message.length - UITools.AMOUNT_SUBCOAT_HT_CONTENT));
		}
		UITools.drawTitle(g, "家族信息");// 绘制标题
		UITools.drawWindowSoftkey(g,
				GameManager.getInstance().m_role.m_position > 0 ? UITools.BUTTON_INDEX_CAOZUO : 0, UITools.BUTTON_INDEX_FANHUI);// 绘制左右软键
	}
	//家族管理
	private void drawFamilyManage(Graphics g) {
		UITools.drawWindowBackgroud(g);//绘制背景
		drawFamilyLabel(g);//绘制标签
		if (m_family != null) {
			if (GameManager.getInstance().m_role.m_position == FAMILY_POSITION_SHAIKH && m_family.m_dismiss_time > 0) {
				UITools.drawTimeBar(g, X_FAMILY_DISMISS_TIME_BAR, Y_FAMILY_DISMISS_TIME_BAR,
						W_FAMILY_DISMISS_TIME_BAR, m_family.m_dismiss_time, m_family.m_dismiss_total_time);
				UITools.paintLabelStr(g, X_FAMILY_DISMISS_BUTTON, Y_FAMILY_DISMISS_BUTTON, UITools.W_LABEL_BIG, UITools.H_LABEL, "取消", true) ;
				
				if (m_family_dismiss_hint != null) {
					for (int i = 0; i < m_family_dismiss_hint.length; i++) {
						UITools.drawColorString(g, m_family_dismiss_hint[i],
								X_FAMILY_DISMISS_BUTTON + (UITools.W_LABEL_BIG >> 1),
								Y_FAMILY_DISMISS_BUTTON + UITools.H_LABEL + UITools.GAP_WINDOW_SUBCOAT_UP + i * UITools.H_SINGLE_BAR,
								UIManager.getPaletteColor(UIPalette.COLOR_WORD_NOS), Tools.HCENTER_TOP);
					}
				}
				UITools.drawImageSelectBox(g, X_FAMILY_DISMISS_BUTTON,
						Y_FAMILY_DISMISS_BUTTON, UITools.W_BUTTON_BIG, UITools.H_BUTTON);
			} else {
				drawFaimlyManageMenu(g);//绘制菜单
				drawFamilyDonateList(g);//绘制捐献列表
			}
		}
		UITools.drawTitle(g, "家族管理");// 绘制标题
		UITools.drawWindowSoftkey(g, UITools.BUTTON_INDEX_CAOZUO, UITools.BUTTON_INDEX_FANHUI);// 绘制左右软键
	}
	
	private void drawFamilyDonateList(Graphics g) {
		if (m_open_donate_list && m_donate_list_name != null
				&& m_donate_list_num != null && m_donate_list_amount != null) {
			//绘制背景
			UITools.drawWindowSmallBackgroud(g);
			
			//绘制内容
			g.clipRect(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
			for (int i = m_donate_page, y = 0; (i - m_donate_page) < UITools.AMOUNT_SMALL_CONTENT; i++) {
				if (i < m_donate_list_name.length) {
					y = UITools.Y_BG_SMALL + UITools.H_TITLE + (i - m_donate_page) * UITools.H_SINGLE_BAR;
					
					UITools.drawColorString(g, m_donate_list_name[i],
							UITools.X_BG_SMALL + UITools.GAP_LEFT, y,
							UIManager.getPaletteColor(UIPalette.COLOR_WORD_NOS), Tools.LEFT_TOP);
					if (m_donate_page + m_donate_index == i) {
						UITools.drawColorString(g, "<< " + m_donate_list_num[i] + " >>",
								UITools.X_BG_SMALL + UITools.GAP_LEFT + (UITools.W_BG_SMALL >> 1), y,
								UIManager.getPaletteColor(UIPalette.COLOR_WORD_NOS), Tools.HCENTER_TOP);
					} else {
						UITools.drawColorString(g, Integer.toString(m_donate_list_num[i]),
								UITools.X_BG_SMALL + UITools.GAP_LEFT + (UITools.W_BG_SMALL >> 1), y,
								UIManager.getPaletteColor(UIPalette.COLOR_WORD_NOS), Tools.HCENTER_TOP);
					}
					UITools.drawColorString(g, Integer.toString(m_donate_list_amount[i]),
							UITools.X_BG_SMALL + UITools.W_BG_SMALL - UITools.GAP_LEFT, y,
							UIManager.getPaletteColor(UIPalette.COLOR_WORD_NOS), Tools.RIGHT_TOP);
				}
			}
			
			// 绘制标题
			UITools.drawTitle(g, "选择捐献材料",
					UITools.X_BG_SMALL, UITools.Y_BG_SMALL,
					UITools.W_BG_SMALL, UITools.H_TITLE);
			//绘制左右软键
			UITools.drawWindowSoftkey(g, FAMILY_SOFTKEY_OK, FAMILY_SOFTKEY_BACK,
					UITools.X_BG_SMALL,
					UITools.Y_BG_SMALL,
					UITools.W_BG_SMALL,
					UITools.H_BG_SMALL);
		}
	}

	//家族成员
	private void drawFamilyMember(Graphics g) {
		UITools.drawWindowBackgroud(g);//绘制背景
		drawFamilyLabel(g);//绘制标签
		drawFamilyMemberListContent(g);
		UITools.drawTitle(g, "家族成员");// 绘制标题
		UITools.drawWindowSoftkey(g, UITools.BUTTON_INDEX_CAOZUO, UITools.BUTTON_INDEX_FANHUI);// 绘制左右软键
	}
	//家族申请
	private void drawFamilyApply(Graphics g) {
		UITools.drawWindowBackgroud(g);//绘制背景
		drawFamilyLabel(g);//绘制标签
		drawFamilyApplyListContent(g);
		UITools.drawTitle(g, "家族申请");// 绘制标题
		UITools.drawWindowSoftkey(g, UITools.BUTTON_INDEX_CAOZUO, UITools.BUTTON_INDEX_FANHUI);// 绘制左右软键
	}
	//家族活动
	private void drawFamilyEvent(Graphics g) {
		UITools.drawWindowBackgroud(g);//绘制背景
		drawFamilyLabel(g);//绘制标签
		drawFaimlyEventMenu(g);//绘制活动菜单
		UITools.drawTitle(g, "家族活动");// 绘制标题
	}
	
//	// 绘制家族列表
//	private void drawFamilyList(Graphics g) {
//		UITools.drawWindowBackgroud(g);//绘制背景
//		drawFamilyListContent(g);//绘制内容框
//		UITools.drawTitle(g, "家族列表");// 绘制标题
//		UITools.drawWindowSoftkey(g, FAMILY_SOFTKEY_OPERATE, FAMILY_SOFTKEY_BACK);// 绘制左右软键
//	}
	/**
	 * 绘制活动界面菜单
	 * @param g
	 */
	private void drawFaimlyEventMenu(Graphics g) {
		int sy = Y_FAMILY_MANAGE_MENU - (FAMILY_EVENT_MENU.length * UITools.H_BUTTON >> 1);
		for (int i = 0, y = 0; i < FAMILY_EVENT_MENU.length; i++) {
			y = sy + i * UITools.H_BUTTON;
			g.setClip(X_FAMILY_MANAGE_MENU - (UITools.W_BUTTON_HUGE >> 1), y, UITools.W_BUTTON_HUGE, UITools.H_BUTTON);
			if (i == m_family_event_index) {
				UITools.paintLabelStr(g, X_FAMILY_MANAGE_MENU - (UITools.W_LABEL_HUGE >> 1), y, UITools.W_LABEL_HUGE, UITools.H_LABEL, FAMILY_EVENT_MENU[i], true);
				UITools.drawImageSelectBox(g, X_FAMILY_MANAGE_MENU - (UITools.W_BUTTON_HUGE >> 1), y, UITools.W_BUTTON_HUGE, UITools.H_BUTTON);
			} else {
				UITools.paintLabelStr(g, X_FAMILY_MANAGE_MENU - (UITools.W_LABEL_HUGE >> 1), y, UITools.W_LABEL_HUGE, UITools.H_LABEL, FAMILY_EVENT_MENU[i], false);
			}
		}
	}
	/**
	 * 绘制家族申请列表内容
	 * @param g
	 */
	private void drawFamilyApplyListContent(Graphics g) {
		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
		for (int i = 0; i < AMOUNT_FAMILY_APPLY_LIST; i++) {
			if (i % 2 == 0) {
				UITools.drawColorFillRect(g,
						X_FAMILY_APPLY_LIST, Y_FAMILY_APPLY_LIST + (UITools.H_SUBCOAT_SIDE >> 1) + i * UITools.H_SINGLE_BAR,
						W_FAMILY_APPLY_LIST, UITools.H_SINGLE_BAR, UIManager.getPaletteColor(UIPalette.COLOR_CBD_DEEP));
			} else {
				UITools.drawColorFillRect(g,
						X_FAMILY_APPLY_LIST, Y_FAMILY_APPLY_LIST + (UITools.H_SUBCOAT_SIDE >> 1) + i * UITools.H_SINGLE_BAR,
						W_FAMILY_APPLY_LIST, UITools.H_SINGLE_BAR, UIManager.getPaletteColor(UIPalette.COLOR_CBD_LIGHT));
			}
		}
		if (m_family_apply_list != null) {
			for (int i = 0, y = 0; i < m_family_apply_list.size(); i++) {
				Function func = (Function)m_family_apply_list.elementAt(i);
				y = Y_FAMILY_APPLY_LIST + UITools.GAP_UP + i * UITools.H_SINGLE_BAR;
				if (func.m_type == FAMILY_APPLY_TYPE_FAMILY) {
					UITools.drawColorString(g, FAMILY_BRACE_LEFT + func.m_name + FAMILY_BRACE_RIGHT + FAMILY_MERGE_ADD,
							X_FAMILY_APPLY_LIST + UITools.GAP_LEFT,
							y, UIManager.getPaletteColor(UIPalette.COLOR_WORD_NOS), Tools.LEFT_TOP);
				} else if (func.m_type == FAMILY_APPLY_TYPE_ROLE) {
					UITools.drawColorString(g, FAMILY_BRACE_LEFT + func.m_name + FAMILY_BRACE_RIGHT + FAMILY_APPLY_ADD,
							X_FAMILY_APPLY_LIST + UITools.GAP_LEFT,
							y, UIManager.getPaletteColor(UIPalette.COLOR_WORD_NOS), Tools.LEFT_TOP);
				}
			}
		}
		UITools.drawWindowSubcoat(g, X_FAMILY_APPLY_LIST, Y_FAMILY_APPLY_LIST,
				W_FAMILY_APPLY_LIST, H_FAMILY_APPLY_LIST);
		
		if (m_family_apply_list != null && m_family_apply_list.size() > 0) {
			g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
			UITools.drawSelectBox(g, X_FAMILY_MEMBER_LIST_NAME,
					Y_FAMILY_APPLY_LIST + (UITools.H_SUBCOAT_SIDE >> 1) + m_family_apply_index * UITools.H_SINGLE_BAR,
					W_FAMILY_APPLY_LIST, UITools.H_SINGLE_BAR);
		}
		
		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
		UITools.drawPageNumber(g, UITools.X_BG + (UITools.W_BG >> 1), UITools.Y_BG + UITools.H_BG - UITools.GAP_EACH_LINE,
				m_family_apply_page, m_family_apply_amount);
	}
	/**
	 * 绘制家族成员列表
	 * @param g
	 */
	private void drawFamilyMemberListContent(Graphics g) {
		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
		for (int i = 0; i < AMOUNT_FAMILY_MEMBER_LIST; i++) {
			if (i % 2 == 0) {
				UITools.drawColorFillRect(g,
						X_FAMILY_MEMBER_LIST_NAME,
						Y_FAMILY_MEMBER_LIST_NAME + (UITools.H_SUBCOAT_SIDE >> 1) + i * UITools.H_SINGLE_BAR,
						W_FAMILY_MEMBER_LIST_NAME, UITools.H_SINGLE_BAR,
						UIManager.getPaletteColor(UIPalette.COLOR_CBD_DEEP));
				UITools.drawColorFillRect(g,
						X_FAMILY_MEMBER_LIST_LV,
						Y_FAMILY_MEMBER_LIST_LV + (UITools.H_SUBCOAT_SIDE >> 1) + i * UITools.H_SINGLE_BAR,
						W_FAMILY_MEMBER_LIST_LV, UITools.H_SINGLE_BAR,
						UIManager.getPaletteColor(UIPalette.COLOR_CBD_DEEP));
				UITools.drawColorFillRect(g,
						X_FAMILY_MEMBER_LIST_JOB,
						Y_FAMILY_MEMBER_LIST_JOB + (UITools.H_SUBCOAT_SIDE >> 1) + i * UITools.H_SINGLE_BAR,
						W_FAMILY_MEMBER_LIST_JOB, UITools.H_SINGLE_BAR,
						UIManager.getPaletteColor(UIPalette.COLOR_CBD_DEEP));
			} else {
				UITools.drawColorFillRect(g,
						X_FAMILY_MEMBER_LIST_NAME,
						Y_FAMILY_MEMBER_LIST_NAME + (UITools.H_SUBCOAT_SIDE >> 1) + i * UITools.H_SINGLE_BAR,
						W_FAMILY_MEMBER_LIST_NAME, UITools.H_SINGLE_BAR,
						UIManager.getPaletteColor(UIPalette.COLOR_CBD_LIGHT));
				UITools.drawColorFillRect(g,
						X_FAMILY_MEMBER_LIST_LV,
						Y_FAMILY_MEMBER_LIST_LV + (UITools.H_SUBCOAT_SIDE >> 1) + i * UITools.H_SINGLE_BAR,
						W_FAMILY_MEMBER_LIST_LV, UITools.H_SINGLE_BAR,
						UIManager.getPaletteColor(UIPalette.COLOR_CBD_LIGHT));
				UITools.drawColorFillRect(g,
						X_FAMILY_MEMBER_LIST_JOB,
						Y_FAMILY_MEMBER_LIST_JOB + (UITools.H_SUBCOAT_SIDE >> 1) + i * UITools.H_SINGLE_BAR,
						W_FAMILY_MEMBER_LIST_JOB, UITools.H_SINGLE_BAR,
						UIManager.getPaletteColor(UIPalette.COLOR_CBD_LIGHT));
			}
		}
		if (m_family_member_list != null) {
			for (int i = 0, y = 0; i < m_family_member_list.size(); i++) {
				ActorRole role = (ActorRole)m_family_member_list.elementAt(i);
				y = Y_FAMILY_MEMBER_LIST_NAME + UITools.GAP_UP + i * UITools.H_SINGLE_BAR;
				if (role.m_online) {
					int color = role.m_position == FAMILY_POSITION_SHAIKH ? Tools.RED : (role.m_position == FAMILY_POSITION_ELDER ? Tools.YELLOW : Tools.WHITE);
					UITools.drawColorString(g, role.m_name,
							X_FAMILY_MEMBER_LIST_NAME + UITools.GAP_LEFT,
							y, color, Tools.LEFT_TOP);
					UITools.drawColorString(g, role.m_lv <= 0 ? "－" : Integer.toString(role.m_lv),
							X_FAMILY_MEMBER_LIST_LV + (W_FAMILY_MEMBER_LIST_LV >> 1),
							y, color, Tools.HCENTER_TOP);
					UITools.drawColorString(g, ActorRole.FAMILY_POSITION_LIST[role.m_position],
							X_FAMILY_MEMBER_LIST_JOB + (W_FAMILY_MEMBER_LIST_JOB >> 1),
							y, color, Tools.HCENTER_TOP);
				} else {
					UITools.drawColorString(g, role.m_name,
							X_FAMILY_MEMBER_LIST_NAME + UITools.GAP_LEFT,
							y, 0x4a3e3c, Tools.LEFT_TOP);
					UITools.drawColorString(g, role.m_lv <= 0 ? "－" : Integer.toString(role.m_lv),
							X_FAMILY_MEMBER_LIST_LV + (W_FAMILY_MEMBER_LIST_LV >> 1),
							y, 0x4a3e3c, Tools.HCENTER_TOP);
					UITools.drawColorString(g, ActorRole.FAMILY_POSITION_LIST[role.m_position],
							X_FAMILY_MEMBER_LIST_JOB + (W_FAMILY_MEMBER_LIST_JOB >> 1),
							y, 0x4a3e3c, Tools.HCENTER_TOP);
				}
			}
		}
		UITools.drawWindowSubcoat(g,//绘制名字标签
				X_FAMILY_MEMBER_LIST_NAME_LABEL, Y_FAMILY_MEMBER_LIST_NAME_LABEL,
				W_FAMILY_MEMBER_LIST_NAME_LABEL, H_FAMILY_MEMBER_LIST_NAME_LABEL,
				UIManager.getPaletteColor(UIPalette.COLOR_TITLE));
		UITools.drawColorString(g,//名字
				FAMILY_MEMBER_LABEL[FAMILY_MEMBER_LIST_NAME],
				X_FAMILY_MEMBER_LIST_NAME_LABEL + (W_FAMILY_MEMBER_LIST_NAME_LABEL >> 1),
				Y_FAMILY_MEMBER_LIST_NAME_LABEL + UITools.GAP_UP,
				UIManager.getPaletteColor(UIPalette.COLOR_WORD_NOS), Tools.HCENTER_TOP);
		UITools.drawWindowSubcoat(g,//绘制等级标签
				X_FAMILY_MEMBER_LIST_LV_LABEL, Y_FAMILY_MEMBER_LIST_LV_LABEL,
				W_FAMILY_MEMBER_LIST_LV_LABEL, H_FAMILY_MEMBER_LIST_LV_LABEL,
				UIManager.getPaletteColor(UIPalette.COLOR_TITLE));
		UITools.drawColorString(g,//等级
				FAMILY_MEMBER_LABEL[FAMILY_MEMBER_LIST_LV],
				X_FAMILY_MEMBER_LIST_LV_LABEL + (W_FAMILY_MEMBER_LIST_LV_LABEL >> 1),
				Y_FAMILY_MEMBER_LIST_LV_LABEL + UITools.GAP_UP,
				UIManager.getPaletteColor(UIPalette.COLOR_WORD_NOS), Tools.HCENTER_TOP);
		UITools.drawWindowSubcoat(g,//绘制人数标签
				X_FAMILY_MEMBER_LIST_JOB_LABEL, Y_FAMILY_MEMBER_LIST_JOB_LABEL,
				W_FAMILY_MEMBER_LIST_JOB_LABEL, H_FAMILY_MEMBER_LIST_JOB_LABEL,
				UIManager.getPaletteColor(UIPalette.COLOR_TITLE));
		UITools.drawColorString(g,//职业
				FAMILY_MEMBER_LABEL[FAMILY_MEMBER_LIST_JOB],
				X_FAMILY_MEMBER_LIST_JOB_LABEL + (W_FAMILY_MEMBER_LIST_JOB_LABEL >> 1),
				Y_FAMILY_MEMBER_LIST_JOB_LABEL + UITools.GAP_UP,
				UIManager.getPaletteColor(UIPalette.COLOR_WORD_NOS), Tools.HCENTER_TOP);
		UITools.drawWindowSubcoat(g,//绘制名字背景框
				X_FAMILY_MEMBER_LIST_NAME, Y_FAMILY_MEMBER_LIST_NAME,
				W_FAMILY_MEMBER_LIST_NAME, H_FAMILY_MEMBER_LIST_NAME);
		UITools.drawWindowSubcoat(g,//绘制等级背景框
				X_FAMILY_MEMBER_LIST_LV, Y_FAMILY_MEMBER_LIST_LV,
				W_FAMILY_MEMBER_LIST_LV, H_FAMILY_MEMBER_LIST_LV);
		UITools.drawWindowSubcoat(g,//绘制职业背景框
				X_FAMILY_MEMBER_LIST_JOB, Y_FAMILY_MEMBER_LIST_JOB,
				W_FAMILY_MEMBER_LIST_JOB, H_FAMILY_MEMBER_LIST_JOB);
		
		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
		UITools.drawSelectBox(g, X_FAMILY_MEMBER_LIST_NAME,
				Y_FAMILY_MEMBER_LIST_NAME + (UITools.H_SUBCOAT_SIDE >> 1) + m_family_member_index * UITools.H_SINGLE_BAR,
				W_FAMILY_MEMBER_LIST, UITools.H_SINGLE_BAR);
		
		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
		UITools.drawPageNumber(g, UITools.X_BG + (UITools.W_BG >> 1), UITools.Y_BG + UITools.H_BG - UITools.GAP_EACH_LINE,
				m_family_member_page, m_family_member_amount);
	}
	/**
	 * 绘制家族列表内容栏
	 * @param g
	 */
//	private void drawFamilyListContent(Graphics g) {
////		for (int i = 0; i < AMOUNT_FAMILY_LIST; i++) {
////			if (i % 2 == 0) {
////				UITools.drawColorFillRect(g,
////						X_FAMILY_LIST_NAME,
////						Y_FAMILY_LIST_NAME + (UITools.H_SUBCOAT_SIDE >> 1) + i * UITools.H_SINGLE_BAR,
////						W_FAMILY_LIST_NAME, UITools.H_SINGLE_BAR,
////						UIManager.getPaletteColor(UIPalette.COLOR_CBD_DEEP));
////				UITools.drawColorFillRect(g,
////						X_FAMILY_LIST_LV,
////						Y_FAMILY_LIST_LV + (UITools.H_SUBCOAT_SIDE >> 1) + i * UITools.H_SINGLE_BAR,
////						W_FAMILY_LIST_LV, UITools.H_SINGLE_BAR,
////						UIManager.getPaletteColor(UIPalette.COLOR_CBD_DEEP));
////				UITools.drawColorFillRect(g,
////						X_FAMILY_LIST_NNT,
////						Y_FAMILY_LIST_NNT + (UITools.H_SUBCOAT_SIDE >> 1) + i * UITools.H_SINGLE_BAR,
////						W_FAMILY_LIST_NNT, UITools.H_SINGLE_BAR,
////						UIManager.getPaletteColor(UIPalette.COLOR_CBD_DEEP));
////			} else {
////				UITools.drawColorFillRect(g,
////						X_FAMILY_LIST_NAME,
////						Y_FAMILY_LIST_NAME + (UITools.H_SUBCOAT_SIDE >> 1) + i * UITools.H_SINGLE_BAR,
////						W_FAMILY_LIST_NAME, UITools.H_SINGLE_BAR,
////						UIManager.getPaletteColor(UIPalette.COLOR_CBD_LIGHT));
////				UITools.drawColorFillRect(g,
////						X_FAMILY_LIST_LV,
////						Y_FAMILY_LIST_LV + (UITools.H_SUBCOAT_SIDE >> 1) + i * UITools.H_SINGLE_BAR,
////						W_FAMILY_LIST_LV, UITools.H_SINGLE_BAR,
////						UIManager.getPaletteColor(UIPalette.COLOR_CBD_LIGHT));
////				UITools.drawColorFillRect(g,
////						X_FAMILY_LIST_NNT,
////						Y_FAMILY_LIST_NNT + (UITools.H_SUBCOAT_SIDE >> 1) + i * UITools.H_SINGLE_BAR,
////						W_FAMILY_LIST_NNT, UITools.H_SINGLE_BAR,
////						UIManager.getPaletteColor(UIPalette.COLOR_CBD_LIGHT));
////			}
////		}
//		if (m_family_list != null) {
//			for (int i = 0, y = 0; i < m_family_list.size(); i++) {
//				Family family = (Family)m_family_list.elementAt(i);
//				y = (UITools.H_SUBCOAT_SIDE >> 1) + Y_FAMILY_LIST_NAME
//					+ (UITools.H_SINGLE_BAR >> 1) - (AbstractGameScreen.FONT_H >> 1) + i * UITools.H_SINGLE_BAR;
//				g.setClip(X_FAMILY_LIST_NAME, Y_FAMILY_LIST_NAME, W_FAMILY_LIST_NAME, H_FAMILY_LIST_NAME);
//				if (m_family_list_index == i) {
//					UITools.drawColorString(g, family.m_name,
//							X_FAMILY_LIST_NAME + UITools.GAP_LEFT - m_roll_offset_x, y,
//							UIManager.getPaletteColor(UIPalette.COLOR_WORD_NOS), Tools.LEFT_TOP);
//				} else {
//					UITools.drawColorString(g, family.m_name,
//							X_FAMILY_LIST_NAME + UITools.GAP_LEFT, y,
//							UIManager.getPaletteColor(UIPalette.COLOR_WORD_NOS), Tools.LEFT_TOP);
//				}
//				g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
//				UITools.drawColorString(g, Integer.toString(family.m_lv),
//						X_FAMILY_LIST_LV + (W_FAMILY_LIST_LV >> 1), y,
//						UIManager.getPaletteColor(UIPalette.COLOR_WORD_NOS), Tools.HCENTER_TOP);
//				UITools.drawColorString(g, family.m_nnt + "/" + family.m_nnt_max,
//						X_FAMILY_LIST_NNT + (W_FAMILY_LIST_NNT >> 1), y,
//						UIManager.getPaletteColor(UIPalette.COLOR_WORD_NOS), Tools.HCENTER_TOP);
//			}
//		}
//		UITools.drawWindowSubcoat(g,//绘制名字标签
//				X_FAMILY_LIST_NAME_LABEL, Y_FAMILY_LIST_NAME_LABEL,
//				W_FAMILY_LIST_NAME_LABEL, H_FAMILY_LIST_NAME_LABEL,
//				UIManager.getPaletteColor(UIPalette.COLOR_TITLE));
//		UITools.drawColorString(g,//名字
//				FAMILY_LIST_LABEL[FAMILY_LIST_NAME],
//				X_FAMILY_LIST_NAME_LABEL + (W_FAMILY_LIST_NAME_LABEL >> 1),
//				Y_FAMILY_LIST_NAME_LABEL + (H_FAMILY_LIST_NAME_LABEL >> 1) - (AbstractGameScreen.FONT_H >> 1),
//				Tools.WHITE, Tools.HCENTER_TOP);
//		UITools.drawWindowSubcoat(g,//绘制等级标签
//				X_FAMILY_LIST_LV_LABEL, Y_FAMILY_LIST_LV_LABEL,
//				W_FAMILY_LIST_LV_LABEL, H_FAMILY_LIST_LV_LABEL,
//				UIManager.getPaletteColor(UIPalette.COLOR_TITLE));
//		UITools.drawColorString(g,//等级
//				FAMILY_LIST_LABEL[FAMILY_LIST_LV],
//				X_FAMILY_LIST_LV_LABEL + (W_FAMILY_LIST_LV_LABEL >> 1),
//				Y_FAMILY_LIST_LV_LABEL + (H_FAMILY_LIST_LV_LABEL >> 1) - (AbstractGameScreen.FONT_H >> 1),
//				Tools.WHITE, Tools.HCENTER_TOP);
//		UITools.drawWindowSubcoat(g,//绘制人数标签
//				X_FAMILY_LIST_NNT_LABEL, Y_FAMILY_LIST_NNT_LABEL,
//				W_FAMILY_LIST_NNT_LABEL, H_FAMILY_LIST_NNT_LABEL,
//				UIManager.getPaletteColor(UIPalette.COLOR_TITLE));
//		UITools.drawColorString(g,//人数
//				FAMILY_LIST_LABEL[FAMILY_LIST_NNT],
//				X_FAMILY_LIST_NNT_LABEL + (W_FAMILY_LIST_NNT_LABEL >> 1),
//				Y_FAMILY_LIST_NNT_LABEL + (H_FAMILY_LIST_NNT_LABEL >> 1) - (AbstractGameScreen.FONT_H >> 1),
//				Tools.WHITE, Tools.HCENTER_TOP);
//		UITools.drawWindowSubcoat(g,//绘制名字背景框
//				X_FAMILY_LIST_NAME, Y_FAMILY_LIST_NAME,
//				W_FAMILY_LIST_NAME, H_FAMILY_LIST_NAME);
//		UITools.drawWindowSubcoat(g,//绘制等级背景框
//				X_FAMILY_LIST_LV, Y_FAMILY_LIST_LV,
//				W_FAMILY_LIST_LV, H_FAMILY_LIST_LV);
//		UITools.drawWindowSubcoat(g,//绘制人数背景框
//				X_FAMILY_LIST_NNT, Y_FAMILY_LIST_NNT,
//				W_FAMILY_LIST_NNT, H_FAMILY_LIST_NNT);
//		if (m_family_list != null && m_family_list.size() > 0) {
//			g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
//			UITools.drawSelectBox(g, X_FAMILY_LIST_NAME,
//					(UITools.H_SUBCOAT_SIDE >> 1) + Y_FAMILY_LIST_NAME + m_family_list_index * UITools.H_SINGLE_BAR,
//					W_FAMILY_LIST, UITools.H_SINGLE_BAR);
//		}
//		if (m_family_list_amount > 0) {
//			g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
//			UITools.drawPageNumber(g, UITools.X_BG + (UITools.W_BG >> 1), UITools.Y_BG + UITools.H_BG - UITools.GAP_EACH_LINE,
//					m_family_list_page, m_family_list_amount);
//		}
//	}
	/**
	 * 绘制其他家族信息
	 * @param g
	 */
	private void drawFamilyOtherMessage(Graphics g) {
		UITools.drawWindowBackgroud(g);//绘制背景
//		drawFamilyLabel(g);//绘制标签
		UITools.drawWindowSubcoat(g,//内层背景
				UITools.X_SUBCOAT_HT, UITools.Y_SUBCOAT_HT,
				UITools.W_SUBCOAT_HT, UITools.H_SUBCOAT_HT, UIManager.getPaletteColor(UIPalette.COLOR_CBD_DEEP));
		UITools.drawStringList(g,
				m_family_message,
				UITools.X_SUBCOAT_HT + UITools.GAP_LEFT,
				UITools.Y_SUBCOAT_HT + UITools.GAP_UP,
				m_family_message_page, UITools.AMOUNT_SUBCOAT_HT_CONTENT, UIManager.getPaletteColor(UIPalette.COLOR_WORD_NOS));
		UITools.drawTitle(g, "家族信息");// 绘制标题
		UITools.drawWindowSoftkey(g, (byte)0, UITools.BUTTON_INDEX_FANHUI);// 绘制左右软键
	}
	/************************通信指令**************************/
	/**
	 * 验证是否可以创建家族
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyVerify(DataInputStream dis) throws IOException {
		short status = dis.readShort();
		if (status == SUCCEED) {
			m_state = FAMILY_STATUS_CREATE;
			changeAdvancedScreen("请输入家族名称", FAMILY_ADVANCED_SHORT);
		} else {
			String msg = dis.readUTF();
			Tools.debugPrintln(msg);
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, msg);
		}
	}
	/**
	 * 创建家族
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyCreate(DataInputStream dis) throws IOException {
		short status = dis.readShort();
		String msg = dis.readUTF();
		if (status == SUCCEED) {
			GameManager.getInstance().m_role.m_position = FAMILY_POSITION_SHAIKH;
			UIManager.getInstance().removeWindow(this);
			Display.getDisplay(GameMIDlet.s_instance).setCurrent(GameMIDlet.s_canvas);
		} else {
			m_hint.setLabel("提示 :");
			m_hint.setText(msg);
		}
	}
	/**
	 * 家族列表
	 * @param dis
	 * @throws IOException
	 */
//	public void recvFamilyList(DataInputStream dis) throws IOException {
//		m_family_list_page = dis.readShort();
//		m_family_list_amount = dis.readShort();
//		short size = dis.readShort();
//		Tools.debugPrintln("cur page : " + m_family_list_page);
//		Tools.debugPrintln("amount page : " + m_family_list_amount);
//		Tools.debugPrintln("size : " + size);
//		if (size > 0) {
//			if (m_family_list != null) {
//				m_family_list.removeAllElements();
//				m_family_list = null;
//			}
//			m_family_list = new ArrayList();
//			for (int i = 0; i < size; i++) {
//				Family family = new Family();
//				family.readList(dis);
//				m_family_list.addElement(family);
//			}
//			Family fam = (Family)m_family_list.elementAt(0);
//			refreshRollTime(AbstractGameScreen.s_font.stringWidth(fam.m_name), W_FAMILY_LIST_NAME);
//		} else {
//			if (m_family_list != null) {
//				m_family_list.removeAllElements();
//				m_family_list = null;
//			}
//		}
//		m_family_list_index = 0;
//		setWindowStatus(FAMILY_STATUS_LIST);
//		if (UIManager.getInstance().getWindowById(UIWindowFactory.WINDOW_ID_FAMILY) == null) {
//			UIManager.getInstance().addWindow(this);
//		}
//	}
	/**
	 * 查看自己家族信息
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyOwnMessage(DataInputStream dis) throws IOException {
		long id = dis.readLong();//家族ID 0失败 不继续读取
		Tools.debugPrintln("读取自己家族信息!" + id);
		if (id >= SUCCEED) {
			m_family = null;
			m_family = new Family();
			m_family.readOwnMessage(dis);
			if (m_family.m_dismiss_time > 0) {
				String temp = FAMILY_DISMISS_HINT1 + UITools.getTimeBySecond(m_family.m_dismiss_total_time) + FAMILY_DISMISS_HINT2;
				m_family_dismiss_hint = UITools.splitString(temp, UITools.W_BG - UITools.H_WIN_SIDE);
			}
			m_family_message = m_family.getOwnMessage();
			m_family_label = FAMILY_STATUS_MESSAGE - 1;
			setWindowStatus(FAMILY_STATUS_MESSAGE);
			if (UIManager.getInstance().getWindowById(UIWindowFactory.WINDOW_ID_FAMILY) == null) {
				this.initStr();
				UIManager.getInstance().addWindow(this);
			}
		} else {
//			GameManager.getInstance().m_game_message.sendFamilyList((short) 0, (short) AMOUNT_FAMILY_LIST);
//			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "没有加入家族!");
			setWindowStatus(FAMILY_STATUS_NOTHAVE);
			if (UIManager.getInstance().getWindowById(UIWindowFactory.WINDOW_ID_FAMILY) == null) {
				this.initStr();
				UIManager.getInstance().addWindow(this);
			}
		}
	}
	/**
	 * 读取修改家族宣言
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyModifyManifesto(DataInputStream dis) throws IOException {
		byte status = dis.readByte();
		Tools.debugPrintln("status : " + status);
		if (status == SUCCEED) {
			m_family.m_manifesto = m_family_content;
			m_family_message = m_family.getOwnMessage();
			Display.getDisplay(GameMIDlet.s_instance).setCurrent(GameMIDlet.s_canvas);
		}
	}
	/**
	 * 读取修改家族公告
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyModifyNotice(DataInputStream dis) throws IOException {
		byte status = dis.readByte();
		Tools.debugPrintln("status : " + status);
		if (status == SUCCEED) {
			m_family.m_notice = m_family_content;
			m_family_message = m_family.getOwnMessage();
			Display.getDisplay(GameMIDlet.s_instance).setCurrent(GameMIDlet.s_canvas);
		}
	}
	/**
	 * 读取更新家族职位
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyUpdatePosition(DataInputStream dis) throws IOException {
		long id = dis.readLong();
		if (id == 0) {
			UIAbstractWindow family = UIManager.getInstance().getWindowById(UIWindowFactory.WINDOW_ID_FAMILY);
			if (family != null) {
				UIManager.getInstance().removeWindow(family);
			}
			GameManager.getInstance().m_role.m_position = 0;
		} else {
			GameManager.getInstance().m_role.m_position = dis.readByte();
			GameManager.getInstance().m_role.m_contribution = dis.readLong();
			Tools.debugPrintln("职位 : " + GameManager.getInstance().m_role.m_position + ", 贡献值 : " + GameManager.getInstance().m_role.m_contribution);
		}
	}
	/**
	 * 读取家族成员列表
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyMemberList(DataInputStream dis) throws IOException {
		byte status = dis.readByte();
		Tools.debugPrintln("status : " + status);
		if (status == 1) {
			m_family_member_page = dis.readShort();
			Tools.debugPrintln("当前页 : " + m_family_member_page);
			m_family_member_amount = dis.readShort();
			Tools.debugPrintln("总页 : " + m_family_member_amount);
			short size = dis.readShort();
//			Tools.debugPrintln("长度 : " + size);
			m_family_member_list = null;
			m_family_member_list = new ArrayList();
			for (short i = 0; i < size; i++) {
				ActorRole role = new ActorRole();
				role.m_gameID = dis.readLong();
//				Tools.debugPrintln("成员" + i + "ID : " + role.m_gameID);
				role.m_name = dis.readUTF();
//				Tools.debugPrintln("成员" + i + "名字 : " + role.m_name);
				role.m_position = dis.readByte();
//				Tools.debugPrintln("成员" + i + "职位 : " + role.m_position);
				role.m_online = dis.readByte() == 0 ? false : true;
//				Tools.debugPrintln("成员" + i + "在线 : " + role.m_online);
				if (role.m_online) {
					role.m_lv = dis.readInt();
//					Tools.debugPrintln("成员" + i + "等级 : " + role.m_lv);
					role.m_contribution = dis.readLong();
//					Tools.debugPrintln("成员" + i + "贡献 : " + role.m_contribution);
				}
				m_family_member_list.addElement(role);
			}
			m_family_member_index = 0;
			m_family_label = FAMILY_STATUS_MEMBER - 1;
			setWindowStatus(FAMILY_STATUS_MEMBER);
		}
	}
	/**
	 * 读取其他家族的信息
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyOtherMessage(DataInputStream dis) throws IOException {
		long familyID = dis.readLong();
		if (familyID > 0) {
			m_family = null;
			m_family = new Family();
			m_family.readOtherMessage(dis);
			m_family_message = m_family.getOtherMessage();
			UIManager.getInstance().removeWindowById(UIWindowFactory.WINDOW_ID_FAMILY);
			if (UIManager.getInstance().getWindowById(UIWindowFactory.WINDOW_ID_FAMILY) == null) {
				UIManager.getInstance().addWindow(this);
			}
			setWindowStatus(FAMILY_STATUS_OTHER);
		}
		
	}
	/**
	 * 读取申请加入家族
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyApplyAdd(DataInputStream dis) throws IOException {
		byte status = dis.readByte();
		Tools.debugPrintln("status : " + status);
		if (status == 0) {
			m_hint.setLabel("提示 : ");
			m_hint.setText("未知错误!");
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "未知错误!");
		} else if (status == 1) {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "申请成功!");
			if (Display.getDisplay(GameMIDlet.s_instance).getCurrent() != GameMIDlet.s_canvas)
				Display.getDisplay(GameMIDlet.s_instance).setCurrent(GameMIDlet.s_canvas);
		} else if (status == 2) {
			m_hint.setLabel("提示 : ");
			m_hint.setText("家族不存在!");
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "家族不存在!");
		} else if (status == 3) {
			m_hint.setLabel("提示 : ");
			m_hint.setText("权限不够!");
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "权限不够!");
		} else if (status == 4) {
			m_hint.setLabel("提示 : ");
			m_hint.setText("家族暂时不接受申请!");
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "家族暂时不接受申请!");
		} else if (status == 5) {
			m_hint.setLabel("提示 : ");
			m_hint.setText("邀请人不在线!");
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "邀请人不在线!");
		} else if (status == 6) {
			m_hint.setLabel("提示 : ");
			m_hint.setText("目标不能被邀请!");
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "目标不能被邀请!");
		} else if (status == 7) {
			m_hint.setLabel("提示 : ");
			m_hint.setText("等待回复中,不可申请!");
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "等待回复中,不可申请!");
		} else if (status == 12) {
			m_hint.setLabel("提示 : ");
			m_hint.setText("不同阵营,不可申请!");
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "不同阵营,不可申请!");
		}
		if (m_popmenu != null) {
			UIManager.getInstance().removeWindow(m_popmenu);
		}
	}
	/**
	 * 读取家族申请列表
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyApplyList(DataInputStream dis) throws IOException {
		byte status = dis.readByte();
		Tools.debugPrintln("status : " + status);
		if (status == SUCCEED) {
			m_family_apply_list = null;
			m_family_apply_list = new ArrayList();
			m_family_apply_page = dis.readShort();
			Tools.debugPrintln("当前页 : " + m_family_apply_page);
			m_family_apply_amount = dis.readShort();
			Tools.debugPrintln("总页 : " + m_family_apply_amount);
			long familyID = dis.readLong();
			Tools.debugPrintln("申请家族ID : " + familyID);
			if (familyID > 0) {
				Function func = new Function();
				func.m_id_long = familyID;
				func.m_name = dis.readUTF();
				Tools.debugPrintln("申请家族名字 : " + func.m_name);
				func.m_type = FAMILY_APPLY_TYPE_FAMILY;
				m_family_apply_list.addElement(func);
			}
			short size = dis.readShort();
			for (int i = 0; i < size; i++) {
				Function func = new Function();
				func.m_id_long = dis.readLong();
				Tools.debugPrintln("申请人ID : " + func.m_id_long);
				func.m_name = dis.readUTF();
				Tools.debugPrintln("申请人名字 : " + func.m_name);
				func.m_type = FAMILY_APPLY_TYPE_ROLE;
				m_family_apply_list.addElement(func);
			}
			m_family_label = FAMILY_STATUS_APPLY - 1;
			m_family_member_page = 0;
			setWindowStatus(FAMILY_STATUS_APPLY);
		}
	}
	/**
	 * 读取通过名字或者ID邀请入族
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyInviteAdd(DataInputStream dis) throws IOException {
		byte status = dis.readByte();
		if (status == 1) {
			Display.getDisplay(GameMIDlet.s_instance).setCurrent(GameMIDlet.s_canvas);
		} else if (status == 2) {
			m_hint.setLabel("提示 :");
			m_hint.setText("家族不存在!");
		} else if (status == 3) {
			m_hint.setLabel("提示 :");
			m_hint.setText("权限不够!");
		} else if (status == 4) {
			m_hint.setLabel("提示 :");
			m_hint.setText("家族暂时不接受申请!");
		} else if (status == 5) {
			m_hint.setLabel("提示 :");
			m_hint.setText("邀请人不在线!");
		} else if (status == 6) {
			m_hint.setLabel("提示 :");
			m_hint.setText("目标正在回应其他家族邀请!");
		} else if (status == 12) {
			m_hint.setLabel("提示 :");
			m_hint.setText("不同阵营,不能邀请加入!");
		}
	}
	/**
	 * 接收家族批准
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyRatify(DataInputStream dis) throws IOException {
		byte status = dis.readByte();
		Tools.debugPrintln("status : " + status);
		if (status == 0) {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "未知错误!");
		} else if (status == 1) {
			GameManager.getInstance().m_game_message.unlockNetwork();
			GameManager.getInstance().m_game_message.sendFamilyApplyList(
					(short)m_family_apply_page, (short)AMOUNT_FAMILY_APPLY_LIST);
		} else if (status == 2) {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "家族不存在!");
		} else if (status == 3) {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "权限不够!");
		}
		if (m_popmenu != null) {
			UIManager.getInstance().removeWindow(m_popmenu);
		}
	}
//	/**
//	 * 申请离开家族
//	 * @param dis
//	 * @throws IOException
//	 */
//	public void recvFamilyApplyLeave(DataInputStream dis) throws IOException {
//		byte status = dis.readByte();
//		Tools.debugPrintln("status : " + status);
//		if (status == 0) {//未知错误
//			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "未知错误!");
//		} else if (status == 1) {//成功
//			m_messagebox = null;
//			m_messagebox = (UIMessageBox)UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_MESSAGEBOX);
//			m_messagebox.setMessage("您确认要离开家族?");
//			m_messagebox.addListener(new UIListener() {
//				public void actionPerformed() {
//					if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
//							|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
//						GameManager.getInstance().m_game_message.sendFamilyConfirmLeave();
//					} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
//						UIManager.getInstance().removeWindow(m_messagebox);
//					}
//				}
//			});
//		} else if (status == 2) {//家族不存在
//			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "家族不存在!");
//		} else if (status == 8) {//不能离开家族
//			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "您是族长,不能离开家族!");
//		}
//	}
	
	/**
	 * 确认离开家族
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyConfirmLeave(DataInputStream dis) throws IOException {
		byte status = dis.readByte();
		if (status == 0) {//未知错误
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "未知错误!");
		} else if (status == 1) {//成功
			if (m_messagebox != null) {
				UIManager.getInstance().removeWindow(m_messagebox);
				UIManager.getInstance().removeWindow(this);
			}
		} else if (status == 2) {//家族不存在
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "家族不存在!");
		} else if (status == 8) {//不能离开家族
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "您是族长,不能离开家族!");
		}
	}
	/**
	 * 读取开除成员
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyExpel(DataInputStream dis) throws IOException {
		byte status = dis.readByte();
		if (status == 0) {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "未知错误!");
		} else if (status == 1) {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "开除成功!");
			if (m_messagebox != null) {
				UIManager.getInstance().removeWindow(m_messagebox);
			}
			if (m_popmenu != null) {
				UIManager.getInstance().removeWindow(m_popmenu);
			}
			GameManager.getInstance().m_game_message.unlockNetwork();
			if (m_family_member_list != null && m_family_member_list.size() == 1) {
				GameManager.getInstance().m_game_message.sendFamilyMemberList(
						(short)0, (short)AMOUNT_FAMILY_MEMBER_LIST);
			} else {
				GameManager.getInstance().m_game_message.sendFamilyMemberList(
						(short)m_family_member_page, (short)AMOUNT_FAMILY_MEMBER_LIST);
			}
		} else if (status == 2) {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "家族不存在!");
		} else if (status == 3) {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "权限不够!");
		} else if (status == 8) {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "您是族长,不能离开家族!");
		}
	}
	/**
	 * 读取解散家族
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyDismiss(DataInputStream dis) throws IOException {
		byte status = dis.readByte();
		Tools.debugPrintln("status : " + status);
		if (status == 0) {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "未知错误!");
		} else if (status == 1) {
			m_family.m_dismiss_time = dis.readLong();
			m_family.m_dismiss_total_time = m_family.m_dismiss_time;
			Tools.debugPrintln("解散剩余时间 : " + m_family.m_dismiss_time);
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "申请解散成功!");
		} else if (status == 2) {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "家族不存在!");
		} else if (status == 3) {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "权限不够!");
		} else if (status == 4) {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "家族不接收申请!");
		}
	}
	/**
	 * 读取取消解散家族
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyCancelDismiss(DataInputStream dis) throws IOException {
		byte status = dis.readByte();
		Tools.debugPrintln("status : " + status);
		if (status == 0) {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "未知错误!");
		} else if (status == 1) {
			m_family.m_dismiss_time = 0;
			m_family.m_dismiss_total_time = m_family.m_dismiss_time;
			Tools.debugPrintln("取消解散时间 : " + m_family.m_dismiss_time);
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "取消解散成功!");
		} else if (status == 2) {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "家族不存在!");
		} else if (status == 3) {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "权限不够!");
		}
	}
	/**
	 * 被邀请加入家族
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyInviteeAdd(DataInputStream dis) throws IOException {
		final Family family = new Family();
		family.m_shaikh_id = dis.readLong();
		Tools.debugPrintln("族长ID : " + family.m_shaikh_id);
		family.m_id = dis.readLong();
		Tools.debugPrintln("家族ID : " + family.m_id);
		family.m_name = dis.readUTF();
		Tools.debugPrintln("家族名字 : " + family.m_name);
		final UIMessageBox mb = (UIMessageBox)UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_MESSAGEBOX);
		mb.setMessage(family.m_name + "家族邀请您加入!");
		mb.addListener(new UIListener() {
			public void actionPerformed() {
				if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
						|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
					GameManager.getInstance().m_game_message.sendFamilyInviteeAdd(FAMILY_INVITEE_AGREE, family.m_shaikh_id, family.m_id);
					UIManager.getInstance().removeWindow(mb);
				} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
					GameManager.getInstance().m_game_message.sendFamilyInviteeAdd(FAMILY_INVITEE_REFUSE, family.m_shaikh_id, family.m_id);
					UIManager.getInstance().removeWindow(mb);
				}
			}
		});
	}
	/**
	 * 读取提拔/免职长老
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilySetElder(DataInputStream dis) throws IOException {
		byte status = dis.readByte();
		Tools.debugPrintln("提拔/免职长老 状态 : " + status);
		if (status == 0) {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "未知错误!");
		} else if (status == 1) {
//			byte type = dis.readByte();
//			Tools.debugPrintln("提拔/免职长老 type : " + type);
//			long id = dis.readLong();
//			Tools.debugPrintln("提拔/免职长老 id : " + id);
//			if (m_family_member_list != null) {
//				ActorRole member = null;
//				for (int i = 0; i < m_family_member_list.size(); i++) {
//					member = (ActorRole)m_family_member_list.elementAt(i);
//					if (member.m_gameID == id) {
//						if (type == 0) {
//							member.m_position = FAMILY_POSITION_ELDER;
//						} else if (type == 1) {
//							member.m_position = FAMILY_POSITION_MEMBER;
//						}
//						return;
//					}
//				}
//				GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "无此成员!");
//			}
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "设置成功!");
			GameManager.getInstance().m_game_message.unlockNetwork();
			GameManager.getInstance().m_game_message.sendFamilyMemberList(
					(short)m_family_member_page, (short)AMOUNT_FAMILY_MEMBER_LIST);
		} else if (status == 2) {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "家族不存在!");
		} else if (status == 3) {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "权限不够!");
		} else if (status == 4) {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "长老名额达到上限!");
		}
	}
	/**
	 * 读取禅让族长
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyDemiseSheikh(DataInputStream dis) throws IOException {
		byte status = dis.readByte();
		if (status == 0) {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "未知错误!");
		} else if (status == 1) {
//			long id = dis.readLong();
//			if (m_family_member_list != null) {
//				ActorRole member = null;
//				for (int i = 0; i < m_family_member_list.size(); i++) {
//					member = (ActorRole)m_family_member_list.elementAt(i);
//					if (member.m_gameID == id) {
//						member.m_position = FAMILY_POSITION_SHAIKH;
//						return;
//					}
//				}
//				GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "无此成员!");
//			}
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "设置成功!");
			GameManager.getInstance().m_game_message.unlockNetwork();
			GameManager.getInstance().m_game_message.sendFamilyMemberList(
					(short)m_family_member_page, (short)AMOUNT_FAMILY_MEMBER_LIST);
		} else if (status == 2) {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "家族不存在!");
		} else if (status == 3) {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "权限不够!");
		} else if (status == 4) {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "对方不接受!");
		}
	}
	/**
	 * 读取合并家族
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyApplyMerge(DataInputStream dis) throws IOException {
		byte status = dis.readByte();
		if (status == 0) {
			m_hint.setLabel("提示 :");
			m_hint.setText("未知错误!!");
		} else if (status == 1) {
			Display.getDisplay(GameMIDlet.s_instance).setCurrent(GameMIDlet.s_canvas);
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "申请合并家族成功!");
		} else if (status == 2) {
			m_hint.setLabel("提示 :");
			m_hint.setText("家族不存在!");
		} else if (status == 3) {
			m_hint.setLabel("提示 :");
			m_hint.setText("权限不够!");
		} else if (status == 4) {
			m_hint.setLabel("提示 :");
			m_hint.setText("合并条件不符合!");
		} else if (status == 9) {
			m_hint.setLabel("提示 :");
			m_hint.setText("需要道具!");
		}
	}
	/**
	 * 读取家族捐献物资
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyDonate(DataInputStream dis) throws IOException {
		byte status = dis.readByte();
		String msg = dis.readUTF();
		if (status == 1) {
			m_open_donate_list = false;
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "获得" + dis.readLong() + "点贡献值!");
		} else {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, msg);
		}
	}
	
	/**
	 * 家族抽奖开启
	 * @param dis
	 * @throws IOException
	 */
	public void recvFamilyLuckOpen(DataInputStream dis) throws IOException {
		byte status = dis.readByte();
		if (status == 1) {
			m_lucky_family_lv = dis.readInt();
			m_lucky_day_count = dis.readInt();
			m_lucky_event_devote = dis.readInt();
			m_lucky_surplus_count = dis.readInt();
			m_lucky_item_amount = dis.readByte();
			if (m_lucky_item_amount > 0) {
				m_lucky_item_num = new short[m_lucky_item_amount];
				m_lucky_item_icon = new short[m_lucky_item_amount];
				m_lucky_item_cover = new short[m_lucky_item_amount];
				for (short i = 0; i < m_lucky_item_amount; i++) {
					m_lucky_item_num[i] = dis.readShort();
					m_lucky_item_icon[i] = dis.readShort();
					m_lucky_item_cover[i] = dis.readShort();
				}
				refreshLuckyMessage();
				setWindowStatus(FAMILY_STATUS_LUCKY);
			} else {
				Tools.debugPrintln("家族抽奖数据错误0道具列表!");
			}
		} else if (status == 0) {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "未知错误!");
		} else {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "没有家族!");
		}
	}
	private void refreshLuckyMessage() {
		String text = "家族等级" + m_lucky_family_lv + Tools.CHANGE_ROW + 
		"每天可以抽奖" + m_lucky_day_count + "次,每次消耗" + m_lucky_event_devote + "贡献值." + Tools.CHANGE_ROW + 
		"当前可抽奖" + m_lucky_surplus_count + "次";
		m_lucky_message = Tools.splitString(text, AbstractGameScreen.s_font, Tools.CHANGE_ROW, UITools.W_BG - 40);
	}
	private int m_lucky_family_lv = 0;//家族等级
	private int m_lucky_day_count = 0;//每天可抽奖次数
	private int m_lucky_event_devote = 0;//每次消耗贡献
	private int m_lucky_surplus_count = 0;//剩余可抽奖次数
	private byte m_lucky_item_amount = 0;//抽奖道具数量
	private short[] m_lucky_item_num = null;//兑换道具数量
	private short[] m_lucky_item_icon = null;//图标
	private short[] m_lucky_item_cover = null;//图标类型
	private String[] m_lucky_message = null;//显示信息
	private String m_lucky_item_name = null;//获奖道具名字
	private short m_lucky_item_len = 0;//获奖道具数量
	public void recvFamilyLuckResult(DataInputStream dis) throws IOException {
		byte status = dis.readByte();
		if (status == 0) {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "未知错误!");
		} else if (status == 1) {
			m_lucky_result = dis.readByte();
			m_lucky_item_name = dis.readUTF();
			m_lucky_item_len = dis.readShort();
			luckyStart();
			m_lucky_surplus_count--;
			refreshLuckyMessage();
		} else if (status == 2) {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "没有家族!");
		} else if (status == 10) {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "抽奖次数用完!");
		} else if (status == 11) {
			GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "家族贡献值不够!");
		}
	}
	public void recvOpenListFamilyShop(DataInputStream dis)
	{

		GameManager.getInstance().m_game_message.unlockNetwork();
		try {		
			byte size = dis.readByte();
			if( size < 1){
				GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_B, "没有符合要求的家族商店！");
				return;
			}
			String[] list = new String[size];
			final int[] oder = new int[size];
			final String[] info = new String[size];
		    for(int i=0;i<size;i++){
		    	list[i] = dis.readUTF();
		    	oder[i] = dis.readInt();
		    	info[i] = dis.readUTF();
		    }
		    final UIPopmenu popmenu = (UIPopmenu) UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_POPMENU);
			popmenu.setPopmenus(list);
			popmenu.addListener(new UIListener() {
				
				public void actionPerformed()
				{

					if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
							|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
						int index = popmenu.getCurrentIndex();
						if( index >=0 && index < oder.length){
							GameManager.getInstance().m_game_message.sendOpenFamilyShop(oder[index],info[index]);
						}
						UIManager.getInstance().removeWindow(popmenu);					
					}else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)){
						UIManager.getInstance().removeWindow(popmenu);
					}				
				}
			});
		}
		catch (IOException e) {
			Tools.debugPrintln("接收打开家族商店列表错误！");
		}
	}
	
	/*********************高级界面*************************/
	private void changeAdvancedScreen(String text, int size) {
		form.deleteAll();
		m_text.setString("");
		m_text.setLabel(text + " : ");
		m_text.setMaxSize(200);
		m_hint.setText("");
		m_hint.setLabel("");
		form.append(m_text);
		form.append(m_hint);
		if (text.equals("请输入要合并的家族名称")) {
			form.append(m_hebin);
		}
		form.addCommand(ok);
		form.addCommand(back);
		form.setCommandListener(this);
		Display.getDisplay(GameMIDlet.s_instance).setCurrent(form);
	}
	private Form form = new Form("请输入");
	private TextField m_text = new TextField("", "", 20, TextField.ANY);
	public StringItem m_hint = new StringItem("", "", StringItem.PLAIN);
	public StringItem m_hebin = new StringItem("", 
			"家族合并规则：" + '\n' +
			"1、邀请家族的等级及成员数量必须大于等于被邀请家族。" + '\n' +
			"2、邀请家族与被邀请家族的人员总数不可超过合并后家族的人口上限。" + '\n' +
			"3、合并后被邀请家族将消失，请慎重决定。", StringItem.PLAIN);
	private Command ok = new Command("确定", Command.OK, 1);
	private Command back = new Command("返回", Command.BACK, 1);
	public void commandAction(Command arg0, Displayable arg1) {
		if (arg0 == ok) {
			switch (m_state) {
				case FAMILY_STATUS_LIST:
					break;
				case FAMILY_STATUS_MESSAGE:
					if (m_message_menu_status == FAMILY_MESSAGE_MENU_MANIFESTO) {
						String temp = m_text.getString();
						if (temp == null || temp.equals("")) {
							m_hint.setLabel("提示 :");
							m_hint.setText("家族宣言不能为空!");
						} else {
							m_family_content = m_text.getString();
							GameManager.getInstance().m_game_message.sendFamilyModifyManifesto(m_family_content);
						}
					} else if (m_message_menu_status == FAMILY_MESSAGE_MENU_NOTICE) {
						String temp = m_text.getString();
						if (temp == null || temp.equals("")) {
							m_hint.setLabel("提示 :");
							m_hint.setText("家族公告不能为空!");
						} else {
							m_family_content = m_text.getString();
							GameManager.getInstance().m_game_message.sendFamilyModifyNotice(m_family_content);
						}
					}
					break;
				case FAMILY_STATUS_MANAGE:
					if (m_family_manage_index == FAMILY_MANAGE_SHAIKH_INVITE) {
						String temp = m_text.getString();
						if (temp == null || temp.equals("")) {
							m_hint.setLabel("提示 :");
							m_hint.setText("用户名不能为空!");
						} else if (temp.length() < 2) {
							m_hint.setLabel("提示 :");
							m_hint.setText("用户名过短!");
						} else if (temp.length() > 6) {
							m_hint.setLabel("提示 :");
							m_hint.setText("用户名过长!");
						}
						else {
							m_family_invite_name = m_text.getString();
							GameManager.getInstance().m_game_message.sendFamilyInviteAddName(m_family_invite_name);
						}
					} else if (m_family_manage_index == FAMILY_MANAGE_SHAIKH_MERGE) {
						String temp = m_text.getString();
						if (temp == null || temp.equals("")) {
							m_hint.setLabel("提示 :");
							m_hint.setText("家族名不能为空!");
						} else {
							m_family_apply_merge = m_text.getString();
							GameManager.getInstance().m_game_message.sendFamilyApplyMerge(m_family_apply_merge);
						}
					}
					break;
				case FAMILY_STATUS_NOTHAVE:
					String text = m_text.getString();
					if (text == null || text.equals("")) {
						m_hint.setLabel("提示 :");
						m_hint.setText("家族名不能为空!");
					} else {
						GameManager.getInstance().m_game_message.sendFamilyApplyAddName(text);
					}
					break;
				default:
					String temp = m_text.getString();
					if (temp == null || temp.equals("")) {
						m_hint.setLabel("提示 :");
						m_hint.setText("家族名不能为空!");
					} else {
						m_family_name = m_text.getString();
						GameManager.getInstance().m_game_message.sendFamilyCreate(m_family_name);
					}
					break;
			}
			
		} else if (arg0 == back) {
			synchronized (AbstractGameScene.m_test) {
				Display.getDisplay(GameMIDlet.s_instance).setCurrent(GameMIDlet.s_canvas);
				switch (m_state) {
					case FAMILY_STATUS_CREATE:
						setWindowStatus(FAMILY_STATUS_NOTHAVE);
						break;
				}
			}
		}
	}
	
	/************************变量,常量,对象**************************/
	private final byte SUCCEED = 1;//成功
	private String m_family_name = null;//家族名称
	private String m_family_invite_name = null;//邀请人的名字
	private String m_family_apply_merge = null;//申请合并家族名字
//	private ArrayList m_family_list = null;//服务器家族列表
	private ArrayList m_family_apply_list = null;//家族申请列表(包含申请合并家族)
	private ArrayList m_family_member_list = null;//家族成员列表
	private int m_family_label = 0;//家族标签索引
	private String[] m_family_message = null;//家族信息数组
	private String[][] m_family_manage_infos = null;//家族管理列表内容介绍
	
//	private boolean m_list_or_label = false;//焦点在标签页还是内容列表, 内容列表true, 标签页false
//	private final boolean FAMILY_FOCUS_LIST = true;//焦点在内容列表
//	private final boolean FAMILY_FOCUS_LABEL = false;//焦点在标签页
	
	private int m_family_message_page = 0;//家族信息当前页数
	private int m_family_manage_index = 0;//家族管理界面菜单索引
	private int m_family_member_index = 0;//家族成员界面索引
	private int m_family_apply_index = 0;//家族申请列表索引
	private int m_family_list_index = 0;//家族列表索引
	private int m_family_event_index = 0;//家族活动索引
	
	private Family m_family = null;//临时的一个家族
	private String m_family_content = null;//临时的家族公告 宣言
	
	private short m_family_list_page = 0;//家族列表当前页数
	private short m_family_list_amount = 0;//家族列表总页数
	
	private short m_family_apply_page = 0;//家族申请列表当前页 从1开始
	private short m_family_apply_amount = 0;//家族申请列表总页数
	
	private short m_family_member_page = 0;//家族成员列表当前页 从1开始
	private short m_family_member_amount = 0;//家族成员列表总页数
	
	private short m_family_nohave_index = 0;//无家族界面下标
	
	private byte m_message_menu_status = 0;//家族信息菜单状态
	private UIPopmenu m_popmenu = null;//家族列表菜单
	private UIMessageBox m_messagebox = null;//家族确认框
	public final String FAMILY_APPLY_ADD = "玩家申请加入!";
	public final String FAMILY_MERGE_ADD = "家族申请合并!";
	public final String FAMILY_BRACE_LEFT = "[";
	public final String FAMILY_BRACE_RIGHT = "]";
	private String[] m_family_dismiss_hint = null;//解散家族提示
	private final String FAMILY_DISMISS_HINT1 = "家族即将在";
	private final String FAMILY_DISMISS_HINT2 = "之内解散,在此之前您随时可以取消解散操作!";
//	public final String[] FAMILY_LABEL = {"信息", "管理", "成员", "申请", "活动"};
	public final String[] FAMILY_LABEL = {"信息", "管理", "成员", "申请"};
	public final String[] FAMILY_MEMBER_LABEL = {"姓名", "级别", "职位"};
	public final String[] FAMILY_NO_HAVE = {"家族排名", "创建家族"};
	public final String[] FAMILY_EVENT_MENU = {"家族抽奖"};
	public final String FAMILY_JOIN = "加入家族名称";
	public final String MANAGE_JUAN = "捐献物资可获得贡献值，换取装备和参与抽奖。";
	public final String MANAGE_CHOU = "家族抽奖使用贡献值抽取装备等物品，家族等级提高可以获得更多更好的物品。";
	public final String MANAGE_RUZU = "邀请入族可以邀请其他玩家加入家族。";
	public final String MANAGE_HEZU = "家族合并可以吞并其它家族。";
	public final String MANAGE_SAN = "解散家族家族的等级名称和贡献值将全部删除，请谨慎选择。";
	public final String MANAGE_TUIZU = "退出家族您的贡献值值将全部删除，请谨慎选择";
	public final String MANAGE_SHOP = "通过贡献值您可以兑换，各种等级段的装备。";
	public final String[][] FAMILY_MANAGE_MENU_INFOS = {
			{MANAGE_JUAN,MANAGE_CHOU,MANAGE_TUIZU,MANAGE_SHOP},
			{MANAGE_JUAN,MANAGE_CHOU,MANAGE_TUIZU,MANAGE_SHOP},
			{MANAGE_JUAN,MANAGE_CHOU,MANAGE_RUZU,MANAGE_TUIZU,MANAGE_SHOP},
			{MANAGE_JUAN,MANAGE_CHOU,MANAGE_RUZU,MANAGE_HEZU,MANAGE_SAN,MANAGE_TUIZU,MANAGE_SHOP}};
	public final String[][] FAMILY_MANAGE_MENU = {
			{"捐献物资", "家族抽奖","退出家族","家族商店"},
			{"捐献物资", "家族抽奖","邀请入族", "退出家族","家族商店"},
			{"捐献物资", "家族抽奖","邀请入族", "家族合并", "家族解散", "退出家族","家族商店"}};
	public final String[][] FAMILY_MEMBER_MENU = {
			{"1.查看信息", "2.发送信件"},
			{"1.查看信息", "2.发送信件", "3.发送群信"},
			{"1.查看信息", "2.发送信件", "3.发送群信", "4.开除成员", "5.禅让族长", "6.提拔长老"},
			{"1.查看信息", "2.发送信件", "3.发送群信", "4.开除成员", "5.禅让族长", "6.免职长老"}};
	public final String[] FAMILY_POSITION = {"成员", "长老", "族长"};
	public final String[] FAMILY_LIST_LABEL = {"名字", "级别", "人数/上限"};//家族列表
	public final String[] FAMILY_MESSAGE_MENU = {"修改宣言", "修改公告"};
	public final String[] FAMILY_LIST_MENU = {"同意", "拒绝", "返回"};
	public final String FAMILY_SOFTKEY_OK = "确定";
	public final String FAMILY_SOFTKEY_OPERATE = "操作";
	public final String FAMILY_SOFTKEY_BACK = "返回";
	
	public final byte FAMILY_MEMBER_MENU_MESSAGE = 0;//查看信息
	public final byte FAMILY_MEMBER_MENU_MAIL = 1;//发送信件
	public final byte FAMILY_MEMBER_MENU_MAILS = 2;//发送群信
	public final byte FAMILY_MEMBER_MENU_EXPEL = 3;//开除成员
	public final byte FAMILY_MEMBER_MENU_ABDICATE = 4;//禅让族长
	public final byte FAMILY_MEMBER_MENU_ELDER = 5;//提拔/免职长老
	
	public final byte FAMILY_LIST_AGREE = 0;//家族列表菜单 - 同意
	public final byte FAMILY_LIST_REFUSE = 1;//家族列表菜单 - 拒绝
	public final byte FAMILY_LIST_EXIT = 2;//家族列表菜单 - 返回
	
	public final byte FAMILY_LEAVE_REFUSE = 0;//取消离开
	public final byte FAMILY_LEAVE_AGREE = 1;//同意离开
	
	public final byte FAMILY_INVITEE_AGREE = 0;//被邀请入族 同意
	public final byte FAMILY_INVITEE_REFUSE = 1;//拒绝
	
	public final byte FAMILY_RATIFY_TYPE_FAMILY = 0;//家族批准类型 - 家族
	public final byte FAMILY_RATIFY_TYPE_ROLE = 1;//家族批准类型 - 玩家
	
	public final byte FAMILY_POSITION_NONE = 0;//无职位
	public final byte FAMILY_POSITION_MEMBER = 1;//成员
	public final byte FAMILY_POSITION_ELDER = 2;//长老
	public final byte FAMILY_POSITION_SHAIKH = 3;//族长
	
	public final byte FAMILY_SETELDER_PROMOTION = 0;//提拔
	public final byte FAMILY_SETELDER_DEPOSE = 1;//免职
	
	private final byte FAMILY_NOHAVE_JOIN = 0;//加入家族索引
	private final byte FAMILY_NOHAVE_LIST = 1;//家族排名索引
	private final byte FAMILY_NOHAVE_CREATE = 2;//创建家族索引
	
	private final byte FAMILY_EVENT_LUCKY = 0;//家族活动 - 抽奖
	
	public final byte FAMILY_MANAGE_MEMBER_DONATE = 0;//成员 - 捐献物资
	public final byte FAMILY_MANAGE_MEMBER_LUCKY = 1;//成员 - 抽奖 
//	public final int FAMILY_MANAGE_MEMBER_RECORD = 1;//成员 - 事件记录
	public final byte FAMILY_MANAGE_MEMBER_EXIT = 2;//成员 - 退出家族
	public final int FAMILY_MANAGE_MEMBER_SHOP = 3;//成员 - 家族商店
	
	public final byte FAMILY_MANAGE_ELDER_DONATE = 0;//长老 - 捐献物资
	public final byte FAMILY_MANAGE_ELDER_LUCKY = 1;//长老 - 抽奖 
	public final byte FAMILY_MANAGE_ELDER_INVITE = 2;//长老 - 邀请入族
//	public final int FAMILY_MANAGE_ELDER_RECORD = 2;//长老  - 事件记录
	public final byte FAMILY_MANAGE_ELDER_EXIT = 3;//长老  - 退出家族
	public final int FAMILY_MANAGE_ELDER_SHOP = 4;//成员 - 家族商店
	
	public final byte FAMILY_MANAGE_SHAIKH_DONATE = 0;//族长 - 捐献物资
	public final byte FAMILY_MANAGE_SHAIKH_LUCKY = 1;//长老 - 抽奖 
	public final byte FAMILY_MANAGE_SHAIKH_INVITE = 2;//族长 - 邀请入族
	public final byte FAMILY_MANAGE_SHAIKH_MERGE = 3;//族长 - 家族合并
	public final byte FAMILY_MANAGE_SHAIKH_DISMISS = 4;//族长 - 家族解散
//	public final int FAMILY_MANAGE_SHAIKH_RECORD = 4;//族长  - 事件记录
	public final byte FAMILY_MANAGE_SHAIKH_EXIT = 5;//族长  - 退出家族
	public final int FAMILY_MANAGE_SHAIKH_SHOP = 6;//成员 - 家族商店
	
	public final byte FAMILY_APPLY_TYPE_FAMILY = 0;//家族申请列表内容类型 - 家族合并
	public final byte FAMILY_APPLY_TYPE_ROLE = 1;//玩家
	
	public final byte FAMILY_MESSAGE_MENU_MANIFESTO = 0;//家族信息修改宣言
	public final byte FAMILY_MESSAGE_MENU_NOTICE = 1;//家族信息修改公告
	
	public final byte FAMILY_LIST_NAME = 0;//家族列表 名字
	public final byte FAMILY_LIST_LV = 1;//家族列表 等级
	public final byte FAMILY_LIST_NNT = 2;// 家族列表 人数/上限
	
	public final byte FAMILY_MEMBER_LIST_NAME = 0;//家族成员列表 名字
	public final byte FAMILY_MEMBER_LIST_LV = 1;//家族成员列表 等级
	public final byte FAMILY_MEMBER_LIST_JOB = 2;//家族成员列表 职业
	
	public final byte AMOUNT_FAMILY_LABEL_PAGE = 3;//家族列表标签显示数量
	
	public final byte FAMILY_LABEL_PRIOR = 0;//前一个标签
	public final byte FAMILY_LABEL_CURRENT = 1;//当前标签
	public final byte FAMILY_LABEL_NEXT = 2;//下一个标签
	
	public final byte FAMILY_STATUS_CREATE = 0;//创建家族状态
	public final byte FAMILY_STATUS_MESSAGE = 1;//家族信息状态
	public final byte FAMILY_STATUS_MANAGE = 2;//家族管理状态
	public final byte FAMILY_STATUS_MEMBER = 3;//家族成员状态
	public final byte FAMILY_STATUS_APPLY = 4;//家族申请状态
	public final byte FAMILY_STATUS_EVENT = 5;//家族活动状态
	public final byte FAMILY_STATUS_LIST = 6;//家族列表状态
	public final byte FAMILY_STATUS_OTHER = 7;//其他家族信息
	public final byte FAMILY_STATUS_NOTHAVE = 8;//没有家族时状态
	public final byte FAMILY_STATUS_LUCKY = 9;//家族抽奖界面
	
	private final short FAMILY_ADVANCED_LONG = 200;
	private final short FAMILY_ADVANCED_SHORT = 10;
	
//	private Image img_title_small = null;// 窗口标题栏
//	private Image img_title_middle = null;// 窗口标题中间块
//	private Image img_select_corner = null;// 选择按钮的角
	
	private int m_roll_time = 0;//当前滚动时间
	private int m_roll_offset_x = 0;//滚动偏移X坐标
	private int m_roll_offset_length = 0;//滚动偏移总长度
	private boolean m_roll_time_end = false;//是开始还是结束 false-开始, end-结束
	private final int ROLL_TIME_START = 2 * GameManager.FRAME_PER_SECOND;//滚动开始停留时间
	private final int ROLL_TIME_END = 1 * GameManager.FRAME_PER_SECOND;//滚动结束停留时间
	
	public void refreshRollTime(int wordw, int rimw) {
		m_roll_offset_x = 0;
		m_roll_offset_length = wordw - rimw - 10;
		m_roll_time = ROLL_TIME_START;
		m_roll_time_end = false;
	}
	public void logicRollTime() {
		if (m_roll_time > 0) {
			m_roll_time--;
			if (m_roll_time_end) {
				m_roll_offset_x = 0;
				m_roll_time = ROLL_TIME_START;
				m_roll_time_end = false;
			} else {
				if (m_roll_time == 0) {
					m_roll_time_end = true;
				}
			}
		} else {
			if (m_roll_offset_x < m_roll_offset_length) {
				m_roll_offset_x++;
			} else {
				m_roll_time = ROLL_TIME_END;
			}
		}
	}
	
	
	// 家族列表常量
	public final int W_FAMILY_LIST_WORD_LV = AbstractGameScreen.s_font.stringWidth("等级");
	public final int W_FAMILY_LIST_WORD_NNT = AbstractGameScreen.s_font.stringWidth("人数/上限");
	public static final int H_FAMILY_LIST = UITools.H_BG - UITools.H_SOFTKEY - UITools.H_TITLE - UITools.GAP_WINDOW_SUBCOAT_UP;
	// 家族列表 - 名字标签
	public final int X_FAMILY_LIST_NAME_LABEL = UITools.X_BG + UITools.GAP_WINDOW_SUBCOAT_LEFT + (UITools.H_WIN_SIDE >> 1);
	public final int Y_FAMILY_LIST_NAME_LABEL = UITools.Y_BG + UITools.H_TITLE + UITools.GAP_WINDOW_SUBCOAT_UP;
	public static final int H_FAMILY_LIST_NAME_LABEL = UITools.H_SINGLE_BAR + UITools.H_SUBCOAT_SIDE;

	public final int W_FAMILY_LIST = UITools.W_BG - UITools.H_SUBCOAT_SIDE - UITools.GAP_WINDOW_SUBCOAT_LEFT - UITools.GAP_WINDOW_SUBCOAT_RIGHT;
	public final int W_FAMILY_LIST_LV_LABEL = W_FAMILY_LIST_WORD_LV + UITools.H_SUBCOAT_SIDE + (UITools.GAP_EACH_LINE << 1);
	public final int W_FAMILY_LIST_NNT_LABEL = W_FAMILY_LIST_WORD_NNT + UITools.H_SUBCOAT_SIDE + (UITools.GAP_EACH_LINE << 1);
	public final int W_FAMILY_LIST_NAME_LABEL = W_FAMILY_LIST - W_FAMILY_LIST_LV_LABEL - W_FAMILY_LIST_NNT_LABEL - (UITools.GAP_EACH_LINE << 1);
	// 家族列表 - 等级标签
	public final int X_FAMILY_LIST_LV_LABEL = X_FAMILY_LIST_NAME_LABEL + W_FAMILY_LIST_NAME_LABEL + UITools.GAP_EACH_LINE;
	public final int Y_FAMILY_LIST_LV_LABEL = Y_FAMILY_LIST_NAME_LABEL;
	public final int H_FAMILY_LIST_LV_LABEL = H_FAMILY_LIST_NAME_LABEL;
	// 家族列表 - 人数/上限标签
	public final int X_FAMILY_LIST_NNT_LABEL = X_FAMILY_LIST_LV_LABEL + W_FAMILY_LIST_LV_LABEL + UITools.GAP_EACH_LINE;
	public final int Y_FAMILY_LIST_NNT_LABEL = Y_FAMILY_LIST_NAME_LABEL;
	public final int H_FAMILY_LIST_NNT_LABEL = H_FAMILY_LIST_NAME_LABEL;

	// 家族列表 - 名字
	public static final int H_FAMILY_LIST_TRUE = H_FAMILY_LIST - H_FAMILY_LIST_NAME_LABEL - UITools.GAP_EACH_LINE;
	public static final int AMOUNT_FAMILY_LIST = (H_FAMILY_LIST_TRUE - UITools.H_SUBCOAT_SIDE) / UITools.H_SINGLE_BAR;

	public final int X_FAMILY_LIST_NAME = X_FAMILY_LIST_NAME_LABEL;
	public final int Y_FAMILY_LIST_NAME = Y_FAMILY_LIST_NAME_LABEL + H_FAMILY_LIST_NAME_LABEL + UITools.GAP_EACH_LINE;
	public final int W_FAMILY_LIST_NAME = W_FAMILY_LIST_NAME_LABEL;
	public final int H_FAMILY_LIST_NAME = AMOUNT_FAMILY_LIST * UITools.H_SINGLE_BAR + UITools.H_SUBCOAT_SIDE;
	// 家族列表 - 等级
	public final int X_FAMILY_LIST_LV = X_FAMILY_LIST_LV_LABEL;
	public final int Y_FAMILY_LIST_LV = Y_FAMILY_LIST_NAME;
	public final int W_FAMILY_LIST_LV = W_FAMILY_LIST_LV_LABEL;
	public final int H_FAMILY_LIST_LV = H_FAMILY_LIST_NAME;
	// 家族列表 - 人数/上限
	public final int X_FAMILY_LIST_NNT = X_FAMILY_LIST_NNT_LABEL;
	public final int Y_FAMILY_LIST_NNT = Y_FAMILY_LIST_NAME;
	public final int W_FAMILY_LIST_NNT = W_FAMILY_LIST_NNT_LABEL;
	public final int H_FAMILY_LIST_NNT = H_FAMILY_LIST_NAME;

	// 家族管理菜单
	public final int X_FAMILY_MANAGE_MENU = UITools.X_BG + (UITools.W_BG >> 1);// 此坐标为中心点坐标
	//public final int Y_FAMILY_MANAGE_MENU = UITools.Y_SUBCOAT_HT + (UITools.H_SUBCOAT_HT_TRUE >> 1);
	public final int FAMILY_MANAGE_MENU_LIST_NUM = 5;
	public final int Y_FAMILY_MANAGE_MENU = UITools.Y_SUBCOAT_HT + UITools.GAP_WINDOW_SUBCOAT_UP;
	public final int Y_FAMILY_MANAGE_MENU_INFOS = UITools.Y_SUBCOAT_HT + 2*UITools.GAP_WINDOW_SUBCOAT_UP + FAMILY_MANAGE_MENU_LIST_NUM*UITools.H_BUTTON;
	public final int H_FAMILY_MANAGE_MENU_INFOS = UITools.H_BG - UITools.H_TITLE - 5*UITools.GAP_WINDOW_SUBCOAT_UP - (FAMILY_MANAGE_MENU_LIST_NUM+2)*UITools.H_BUTTON; 

	// 家族成员列表常量
	public final int W_FAMILY_MEMBER_LIST_WORD_LV = AbstractGameScreen.s_font.stringWidth("等级");
	public final int W_FAMILY_MEMBER_LIST_WORD_JOB = AbstractGameScreen.s_font.stringWidth("职位");
	public final int H_FAMILY_MEMBER_LIST = UITools.H_BG - UITools.H_SOFTKEY - UITools.H_TITLE - UITools.GAP_WINDOW_SUBCOAT_UP - UITools.H_BUTTON;
	// 家族成员列表 - 名字标签
	public final int X_FAMILY_MEMBER_LIST_NAME_LABEL = UITools.X_BG + UITools.GAP_WINDOW_SUBCOAT_LEFT + (UITools.H_WIN_SIDE >> 1);
	public final int Y_FAMILY_MEMBER_LIST_NAME_LABEL = UITools.Y_BG + UITools.H_TITLE + UITools.GAP_WINDOW_SUBCOAT_UP + UITools.H_BUTTON;
	public final int H_FAMILY_MEMBER_LIST_NAME_LABEL = UITools.H_SINGLE_BAR + UITools.H_SUBCOAT_SIDE;

	public final int W_FAMILY_MEMBER_LIST = UITools.W_BG - UITools.H_SUBCOAT_SIDE - UITools.GAP_WINDOW_SUBCOAT_LEFT - UITools.GAP_WINDOW_SUBCOAT_RIGHT;
	public final int W_FAMILY_MEMBER_LIST_LV_LABEL = W_FAMILY_MEMBER_LIST_WORD_LV + UITools.H_SUBCOAT_SIDE + (UITools.GAP_EACH_LINE << 1);
	public final int W_FAMILY_MEMBER_LIST_JOB_LABEL = W_FAMILY_MEMBER_LIST_WORD_JOB + UITools.H_SUBCOAT_SIDE + (UITools.GAP_EACH_LINE << 1);

	public final int W_FAMILY_MEMBER_LIST_NAME_LABEL = 
		W_FAMILY_MEMBER_LIST - W_FAMILY_MEMBER_LIST_LV_LABEL - W_FAMILY_MEMBER_LIST_JOB_LABEL - (UITools.GAP_EACH_LINE << 1);
	// 家族成员列表 - 等级标签
	public final int X_FAMILY_MEMBER_LIST_LV_LABEL =  X_FAMILY_MEMBER_LIST_NAME_LABEL + W_FAMILY_MEMBER_LIST_NAME_LABEL + UITools.GAP_EACH_LINE;
	public final int Y_FAMILY_MEMBER_LIST_LV_LABEL = Y_FAMILY_MEMBER_LIST_NAME_LABEL;
	public final int H_FAMILY_MEMBER_LIST_LV_LABEL = H_FAMILY_MEMBER_LIST_NAME_LABEL;
	// 家族成员列表 - 职业标签
	public final int X_FAMILY_MEMBER_LIST_JOB_LABEL = X_FAMILY_MEMBER_LIST_LV_LABEL + W_FAMILY_MEMBER_LIST_LV_LABEL + UITools.GAP_EACH_LINE;
	public final int Y_FAMILY_MEMBER_LIST_JOB_LABEL = Y_FAMILY_MEMBER_LIST_NAME_LABEL;
	public final int H_FAMILY_MEMBER_LIST_JOB_LABEL = H_FAMILY_MEMBER_LIST_NAME_LABEL;

	// 家族成员列表 - 名字
	public final int H_FAMILY_MEMBER_LIST_TRUE = H_FAMILY_MEMBER_LIST - H_FAMILY_MEMBER_LIST_NAME_LABEL - UITools.GAP_EACH_LINE;
	public final int AMOUNT_FAMILY_MEMBER_LIST = (H_FAMILY_MEMBER_LIST_TRUE - UITools.H_SUBCOAT_SIDE) / UITools.H_SINGLE_BAR;
	public final int X_FAMILY_MEMBER_LIST_NAME = X_FAMILY_MEMBER_LIST_NAME_LABEL;
	public final int Y_FAMILY_MEMBER_LIST_NAME = Y_FAMILY_MEMBER_LIST_NAME_LABEL + H_FAMILY_MEMBER_LIST_NAME_LABEL + UITools.GAP_EACH_LINE;
	public final int W_FAMILY_MEMBER_LIST_NAME = W_FAMILY_MEMBER_LIST_NAME_LABEL;
	public final int H_FAMILY_MEMBER_LIST_NAME = AMOUNT_FAMILY_MEMBER_LIST * UITools.H_SINGLE_BAR + UITools.H_SUBCOAT_SIDE;
	// 家族成员列表 - 等级
	public final int X_FAMILY_MEMBER_LIST_LV = X_FAMILY_MEMBER_LIST_LV_LABEL;
	public final int Y_FAMILY_MEMBER_LIST_LV = Y_FAMILY_MEMBER_LIST_NAME;
	public final int W_FAMILY_MEMBER_LIST_LV = W_FAMILY_MEMBER_LIST_LV_LABEL;
	public final int H_FAMILY_MEMBER_LIST_LV = H_FAMILY_MEMBER_LIST_NAME;
	// 家族成员列表 - 职业
	public final int X_FAMILY_MEMBER_LIST_JOB = X_FAMILY_MEMBER_LIST_JOB_LABEL;
	public final int Y_FAMILY_MEMBER_LIST_JOB = Y_FAMILY_MEMBER_LIST_NAME;
	public final int W_FAMILY_MEMBER_LIST_JOB = W_FAMILY_MEMBER_LIST_JOB_LABEL;
	public final int H_FAMILY_MEMBER_LIST_JOB = H_FAMILY_MEMBER_LIST_NAME;

	// 家族申请列表
	public final int H_FAMILY_APPLY_LIST_TRUE = UITools.H_BG - UITools.H_SOFTKEY - UITools.H_TITLE - UITools.GAP_WINDOW_SUBCOAT_UP - UITools.H_BUTTON;
	public final int AMOUNT_FAMILY_APPLY_LIST = (H_FAMILY_APPLY_LIST_TRUE - UITools.H_SUBCOAT_SIDE) / UITools.H_SINGLE_BAR;

	public final int X_FAMILY_APPLY_LIST = UITools.X_BG + UITools.GAP_WINDOW_SUBCOAT_LEFT + (UITools.H_WIN_SIDE >> 1);
	public final int Y_FAMILY_APPLY_LIST = UITools.Y_BG + UITools.H_TITLE + UITools.GAP_WINDOW_SUBCOAT_UP + UITools.H_BUTTON;
	public final int W_FAMILY_APPLY_LIST = UITools.W_BG - UITools.H_SUBCOAT_SIDE - UITools.GAP_WINDOW_SUBCOAT_LEFT - UITools.GAP_WINDOW_SUBCOAT_RIGHT;
	public final int H_FAMILY_APPLY_LIST = AMOUNT_FAMILY_APPLY_LIST * UITools.H_SINGLE_BAR + UITools.H_SUBCOAT_SIDE;

	// 解散家族倒计时条
	public final int W_FAMILY_DISMISS_TIME_BAR = UITools.W_SUBCOAT_HT / 5 * 3;
	public final int X_FAMILY_DISMISS_TIME_BAR = UITools.X_SUBCOAT_HT + ((UITools.W_SUBCOAT_HT - W_FAMILY_DISMISS_TIME_BAR) >> 1);
	public final int Y_FAMILY_DISMISS_TIME_BAR = UITools.Y_BG + UITools.H_TITLE + UITools.GAP_WINDOW_SUBCOAT_UP + (UITools.H_BUTTON << 1);
	public final int H_FAMILY_DISMISS_TIME_BAR = 10;

	// 解散家族取消按钮
	public final int X_FAMILY_DISMISS_BUTTON = UITools.X_BG + (UITools.W_BG >> 1) - (UITools.W_LABEL_BIG >> 1);
	public final int Y_FAMILY_DISMISS_BUTTON = Y_FAMILY_DISMISS_TIME_BAR + H_FAMILY_DISMISS_TIME_BAR + UITools.GAP_WINDOW_SUBCOAT_UP;
}

class Family {
	public long m_id = 0;//家族ID
	public long m_shaikh_id = 0;//族长ID
	public String m_name = null;//家族名称
	public String m_notice = null;//家族公告 外部
	public String m_manifesto = null;//家族宣言 内部
	public String m_shaikh_name = null;//族长名字
	public int m_lv = 0;//等级
	public int m_nnt = 0;//当前人数
	public int m_nnt_max = 0;//人数上限
	public int m_exp = 0;//当前经验
	public int m_exp_max = 0;//升级经验
	public byte m_faction = 0;//阵营
	public long m_dismiss_time = 0;//解散剩余时间
	public long m_dismiss_total_time = 0;//解散剩余总时间
	/**
	 * 得到其他家族的信息数组
	 */
	public String[] getOtherMessage() {
		String[] notice = UITools.splitString(m_notice, UITools.W_SUBCOAT_HT - UITools.H_SUBCOAT_SIDE);
		String[] text = {
				"家族名称:" + m_name,
				"族长:" + m_shaikh_name,
				"阵营:" + AbstractGameActor.ROLE_FACTION_LIST[m_faction],
				"等级:" + m_lv,
				"人数:" + m_nnt + "/" + m_nnt_max,
				"建设:" + m_exp + "/" + m_exp_max,};
		String[] result = new String[text.length + notice.length + 1];
		for (int i = 0; i < text.length; i++) {
			result[i] = text[i];
		}
		result[text.length] = "家族公告:";
		for (int i = 0; i < notice.length; i++) {
			result[text.length + i + 1] = notice[i];
		}
		return result;
	}
	/**
	 * 得到自己家族的信息数组
	 */
	public String[] getOwnMessage() {
		String[] notice = UITools.splitString(m_notice, UITools.W_SUBCOAT_HT - UITools.H_SUBCOAT_SIDE);
		String[] manifesto = UITools.splitString(m_manifesto, UITools.W_SUBCOAT_HT - UITools.H_SUBCOAT_SIDE);
		String[] text = {
				"家族名称:" + m_name,
				"族长:" + m_shaikh_name,
				"阵营:" + AbstractGameActor.ROLE_FACTION_LIST[m_faction],
				"等级:" + m_lv,
				"人数:" + m_nnt + "/" + m_nnt_max,
				"建设:" + m_exp + "/" + m_exp_max,
				"家族宣言(族长可修改):"};
		String[] result = new String[text.length + notice.length + manifesto.length + 1];
		for (int i = 0; i < text.length; i++) {
			result[i] = text[i];
		}
		for (int i = 0; i < manifesto.length; i++) {
			result[text.length + i] = manifesto[i];
		}
		result[text.length + manifesto.length] = "家族公告(族长可修改):";
		for (int i = 0; i < notice.length; i++) {
			result[text.length + manifesto.length + i + 1] = notice[i];
		}
		return result;
	}
	/**
	 * 读取一个自己家族的信息
	 * @param dis
	 * @throws IOException
	 */
	public void readOwnMessage(DataInputStream dis) throws IOException {
		Tools.debugPrintln("读取一个自己家族信息");
		m_shaikh_id = dis.readLong();
		Tools.debugPrintln("族长ID : " + m_shaikh_id);
		m_shaikh_name = dis.readUTF();
		Tools.debugPrintln("族长名字 : " + m_shaikh_name);
		m_faction = dis.readByte();
		Tools.debugPrintln("家族阵营 : " + m_faction);
		m_name = dis.readUTF();
		Tools.debugPrintln("家族名字 : " + m_name);
		m_lv = dis.readInt();
		Tools.debugPrintln("家族等级 : " + m_lv);
		m_exp = dis.readInt();
		Tools.debugPrintln("当前经验 : " + m_exp);
		m_exp_max = dis.readInt();
		Tools.debugPrintln("升级经验 : " + m_exp_max);
		m_manifesto = dis.readUTF();
		Tools.debugPrintln("家族宣言 : " + m_manifesto);
		m_notice = dis.readUTF();
		Tools.debugPrintln("家族公告 : " + m_notice);
		m_nnt = dis.readInt();
		Tools.debugPrintln("家族人数 : " + m_nnt);
		m_nnt_max = dis.readInt();
		Tools.debugPrintln("人数上限 : " + m_nnt_max);
		m_dismiss_time = dis.readLong();
		Tools.debugPrintln("解散时间 : " + m_dismiss_time);
		if (m_dismiss_time > 0) {
			m_dismiss_total_time = dis.readLong();
			Tools.debugPrintln("解散时间上限 : " + m_dismiss_total_time);
		}
	}
	/**
	 * 读取一个其他家族的信息
	 * @param dis
	 * @throws IOException
	 */
	public void readOtherMessage(DataInputStream dis) throws IOException {
		Tools.debugPrintln("读取一个自己家族信息");
		m_shaikh_id = dis.readLong();
		Tools.debugPrintln("族长ID : " + m_shaikh_id);
		m_shaikh_name = dis.readUTF();
		Tools.debugPrintln("族长名字 : " + m_shaikh_name);
		m_faction = dis.readByte();
		Tools.debugPrintln("家族阵营 : " + m_faction);
		m_name = dis.readUTF();
		Tools.debugPrintln("家族名字 : " + m_name);
		m_lv = dis.readInt();
		Tools.debugPrintln("家族等级 : " + m_lv);
		m_exp = dis.readInt();
		Tools.debugPrintln("当前经验 : " + m_exp);
		m_exp_max = dis.readInt();
		Tools.debugPrintln("升级经验 : " + m_exp_max);
		m_notice = dis.readUTF();
		Tools.debugPrintln("家族公告 : " + m_notice);
		m_nnt = dis.readInt();
		Tools.debugPrintln("家族人数 : " + m_nnt);
		m_nnt_max = dis.readInt();
		Tools.debugPrintln("人数上限 : " + m_nnt_max);
	}
	/**
	 * 读取一个家族列表属性
	 * @param dis
	 * @throws IOException
	 */
	public void readList(DataInputStream dis) throws IOException {
		Tools.debugPrintln("读取一个家族列表属性!");
		m_id = dis.readLong();
		Tools.debugPrintln("ID : " + m_id);
		m_name = dis.readUTF();
		Tools.debugPrintln("name : " + m_name);
		m_lv = dis.readInt();
		Tools.debugPrintln("lv : " + m_lv);
		m_nnt = dis.readInt();
		Tools.debugPrintln("nnt : " + m_nnt);
		m_nnt_max = dis.readInt();
		Tools.debugPrintln("nnt max : " + m_nnt_max);
	}
	
	
}
